Skip to content

Commit 6857482

Browse files
committed
Merge pull request pandas-dev#5081 from jtratner/fix-order-of-index-methods
CLN: Fix order of index methods.
2 parents 406e43b + 17d6496 commit 6857482

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

pandas/core/index.py

+29-29
Original file line numberDiff line numberDiff line change
@@ -93,35 +93,6 @@ class Index(FrozenNDArray):
9393

9494
_engine_type = _index.ObjectEngine
9595

96-
def is_(self, other):
97-
"""
98-
More flexible, faster check like ``is`` but that works through views
99-
100-
Note: this is *not* the same as ``Index.identical()``, which checks
101-
that metadata is also the same.
102-
103-
Parameters
104-
----------
105-
other : object
106-
other object to compare against.
107-
108-
Returns
109-
-------
110-
True if both have same underlying data, False otherwise : bool
111-
"""
112-
# use something other than None to be clearer
113-
return self._id is getattr(other, '_id', Ellipsis)
114-
115-
def _reset_identity(self):
116-
"Initializes or resets ``_id`` attribute with new object"
117-
self._id = _Identity()
118-
119-
def view(self, *args, **kwargs):
120-
result = super(Index, self).view(*args, **kwargs)
121-
if isinstance(result, Index):
122-
result._id = self._id
123-
return result
124-
12596
def __new__(cls, data, dtype=None, copy=False, name=None, fastpath=False,
12697
**kwargs):
12798

@@ -187,6 +158,35 @@ def __new__(cls, data, dtype=None, copy=False, name=None, fastpath=False,
187158
subarr._set_names([name])
188159
return subarr
189160

161+
def is_(self, other):
162+
"""
163+
More flexible, faster check like ``is`` but that works through views
164+
165+
Note: this is *not* the same as ``Index.identical()``, which checks
166+
that metadata is also the same.
167+
168+
Parameters
169+
----------
170+
other : object
171+
other object to compare against.
172+
173+
Returns
174+
-------
175+
True if both have same underlying data, False otherwise : bool
176+
"""
177+
# use something other than None to be clearer
178+
return self._id is getattr(other, '_id', Ellipsis)
179+
180+
def _reset_identity(self):
181+
"Initializes or resets ``_id`` attribute with new object"
182+
self._id = _Identity()
183+
184+
def view(self, *args, **kwargs):
185+
result = super(Index, self).view(*args, **kwargs)
186+
if isinstance(result, Index):
187+
result._id = self._id
188+
return result
189+
190190
# construction helpers
191191
@classmethod
192192
def _scalar_data_error(cls, data):

0 commit comments

Comments
 (0)