Skip to content

Commit

Permalink
TEST-#2702: add multiindex loc bench
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Feb 10, 2021
1 parent 76a3d40 commit 7673878
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions asv_bench/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,29 @@ def time_iloc(self, shape, indexer_type):

def time_loc(self, shape, indexer_type):
execute(self.df.loc[self.indexer])


class TimeMultiIndexing:
param_names = ["shape"]
params = [UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE]]

def setup(self, shape):
df = generate_dataframe(ASV_USE_IMPL, "int", *shape, RAND_LOW, RAND_HIGH)

index = pd.MultiIndex.from_product([df.index[: shape[0] // 2], ["bar", "foo"]])
columns = pd.MultiIndex.from_product(
[df.columns[: shape[1] // 2], ["buz", "fuz"]]
)

df.index = index
df.columns = columns

self.df = df.sort_index(axis=1)

def time_multiindex_loc(self, shape):
execute(
self.df.loc[
self.df.index[2] : self.df.index[-2],
self.df.columns[2] : self.df.columns[-2],
]
)

0 comments on commit 7673878

Please sign in to comment.