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

Method setup

asv_bench/benchmarks/reshape.py:118–139  ·  view source on GitHub ↗
(self, dtype)

Source from the content-addressed store, hash-verified

116 params = ["int", "category"]
117
118 def setup(self, dtype):
119 m = 100
120 n = 1000
121
122 levels = np.arange(m)
123 index = MultiIndex.from_product([levels] * 2)
124 columns = np.arange(n)
125 if dtype == "int":
126 values = np.arange(m * m * n).reshape(m * m, n)
127 self.df = DataFrame(values, index, columns)
128 else:
129 # the category branch is ~20x slower than int. So we
130 # cut down the size a bit. Now it's only ~3x slower.
131 n = 50
132 columns = columns[:n]
133 indices = np.random.randint(0, 52, size=(m * m, n))
134 values = np.take(list(string.ascii_letters), indices)
135 values = [pd.Categorical(v) for v in values.T]
136
137 self.df = DataFrame(dict(enumerate(values)), index, columns)
138
139 self.df2 = self.df.iloc[:-1]
140
141 def time_full_product(self, dtype):
142 self.df.unstack()

Callers

nothing calls this directly

Calls 4

DataFrameClass · 0.90
from_productMethod · 0.80
reshapeMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected