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

Method setup

asv_bench/benchmarks/arithmetic.py:133–163  ·  view source on GitHub ↗
(self, op, shape)

Source from the content-addressed store, hash-verified

131 param_names = ["op", "shape"]
132
133 def setup(self, op, shape):
134 # we choose dtypes so as to make the blocks
135 # a) not perfectly match between right and left
136 # b) appreciably bigger than single columns
137 n_rows, n_cols = shape
138
139 if op is operator.floordiv:
140 # floordiv is much slower than the other operations -> use less data
141 n_rows = n_rows // 10
142
143 # construct dataframe with 2 blocks
144 arr1 = np.random.randn(n_rows, n_cols // 2).astype("f8")
145 arr2 = np.random.randn(n_rows, n_cols // 2).astype("f4")
146 df = pd.concat([DataFrame(arr1), DataFrame(arr2)], axis=1, ignore_index=True)
147 # should already be the case, but just to be sure
148 df._consolidate_inplace()
149
150 # TODO: GH#33198 the setting here shouldn't need two steps
151 arr1 = np.random.randn(n_rows, max(n_cols // 4, 3)).astype("f8")
152 arr2 = np.random.randn(n_rows, n_cols // 2).astype("i8")
153 arr3 = np.random.randn(n_rows, n_cols // 4).astype("f8")
154 df2 = pd.concat(
155 [DataFrame(arr1), DataFrame(arr2), DataFrame(arr3)],
156 axis=1,
157 ignore_index=True,
158 )
159 # should already be the case, but just to be sure
160 df2._consolidate_inplace()
161
162 self.left = df
163 self.right = df2
164
165 def time_op_different_blocks(self, op, shape):
166 # blocks (and dtypes) are not aligned

Callers

nothing calls this directly

Calls 5

DataFrameClass · 0.90
maxFunction · 0.85
concatMethod · 0.80
astypeMethod · 0.45
_consolidate_inplaceMethod · 0.45

Tested by

no test coverage detected