From 61747561ef31f6411b739aeb022c6b0cc389eecc Mon Sep 17 00:00:00 2001 From: phofl Date: Thu, 19 Nov 2020 21:10:09 +0100 Subject: [PATCH] CLN: Remove duplicate from MultiIndex.equals --- pandas/core/indexes/multi.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 95f14bb643744..6e18b29673ca0 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -3312,21 +3312,19 @@ def equals(self, other: object) -> bool: if not isinstance(other, Index): return False + if len(self) != len(other): + return False + if not isinstance(other, MultiIndex): # d-level MultiIndex can equal d-tuple Index if not is_object_dtype(other.dtype): # other cannot contain tuples, so cannot match self return False - elif len(self) != len(other): - return False return array_equivalent(self._values, other._values) if self.nlevels != other.nlevels: return False - if len(self) != len(other): - return False - for i in range(self.nlevels): self_codes = self.codes[i] self_codes = self_codes[self_codes != -1]