Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions asv_bench/benchmarks/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,29 @@ def time_apply_index(self, offset):
offset.apply_index(self.rng)


class Sub:
def setup(self):
date_range = pd.date_range("20200101 00:00", "20200102 0:00", freq="S")
level_0_names = [str(i) for i in range(30)]

index = pd.MultiIndex.from_product([level_0_names, date_range])
column_names = ["col_1", "col_2"]

self.df = pd.DataFrame(
np.random.rand(len(index), 2),
index=index,
columns=column_names
)

self.sub_df = pd.DataFrame(
np.random.randint(1, 10, (len(level_0_names), 2)),
index=level_0_names,
columns=column_names,
)

def subsequent_sub_application(self):
self.df.sub(self.sub_df, level=0)
self.df.sub(self.sub_df, level=0)


from .pandas_vb_common import setup # noqa: F401 isort:skip
2 changes: 2 additions & 0 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,8 @@ def equals(self, other) -> bool:
# other cannot contain tuples, so cannot match self
return False

if len(self) != len(other):
return False
return array_equivalent(self._values, other._values)

if self.nlevels != other.nlevels:
Expand Down