You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very simple: both indices get an _id property that can be compared with is and is reset every time an object is created, so it only stays set when set explicitly (like in view(), but not in copy()). Adds an is_ method that wraps this for external use and makes it so you don't need hasattr checks, etc.
>>>ind=Index(range(10))
>>>ind.is_(ind)
True>>>ind.is_(Index(range(10)))
False>>>ind.is_(ind.view().view().view().view())
True>>>ind.is_(ind.copy())
False>>>ind.is_(ind.copy(deep=False))
False>>>ind.is_(ind[:])
False>>>ind.is_(ind.view(np.ndarray).view(Index))
False>>>ind.is_(np.array(range(10)))
False>>>ind.is_(ind.view().base) # quasi-implementation dependentTrue>>>ind2=ind.view()
>>>ind2.name='bob'>>>ind.is_(ind2)
True>>>ind2.is_(ind)
True>>># doesn't matter if Indices are *actually* views of underlying data, e.g.>>>ind.is_(Index(ind.values))
False>>>arr=np.array(range(1, 11))
>>>ind1=Index(arr, copy=False)
>>>ind2=Index(arr, copy=False)
>>>ind1.is_(ind2)
False
MultiIndex behavior (same behavior for set labels and set levels)
Related: #4039 (where this started to become an issue), #4202, #4830, #4628, #4718, #4628.
Very simple: both indices get an
_id
property that can be compared withis
and is reset every time an object is created, so it only stays set when set explicitly (like in view(), but not in copy()). Adds anis_
method that wraps this for external use and makes it so you don't needhasattr
checks, etc.MultiIndex behavior (same behavior for set labels and set levels)
Could make it easier to resolve #4013.
The text was updated successfully, but these errors were encountered: