MCPcopy
hub / github.com/pandas-dev/pandas / setup

Method setup

asv_bench/benchmarks/reshape.py:186–206  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

184
185class PivotTable:
186 def setup(self):
187 N = 100000
188 fac1 = np.array(["A", "B", "C"], dtype="O")
189 fac2 = np.array(["one", "two"], dtype="O")
190 ind1 = np.random.randint(0, 3, size=N)
191 ind2 = np.random.randint(0, 2, size=N)
192 self.df = DataFrame(
193 {
194 "key1": fac1.take(ind1),
195 "key2": fac2.take(ind2),
196 "key3": fac2.take(ind2),
197 "value1": np.random.randn(N),
198 "value2": np.random.randn(N),
199 "value3": np.random.randn(N),
200 }
201 )
202 self.df2 = DataFrame(
203 {"col1": list("abcde"), "col2": list("fghij"), "col3": [1, 2, 3, 4, 5]}
204 )
205 self.df2.col1 = self.df2.col1.astype("category")
206 self.df2.col2 = self.df2.col2.astype("category")
207
208 def time_pivot_table(self):
209 self.df.pivot_table(index="key1", columns=["key2", "key3"])

Callers

nothing calls this directly

Calls 4

DataFrameClass · 0.90
arrayMethod · 0.45
takeMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected