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
I'm happy to make this PR, although I'm not sure whether I'm missing something on the intention. If I'm not, should this be executed by adding something in Index's difference method, or overriding that method in PeriodIndex?
A method that removed items from the index would avoid any subclass-specific code, but the drop method also has some odd behavior:
In [25]:
period_index.drop(period_index)
Out[25]:
Int64Index([], dtype='int64')
So if you're creating a new object, you'd need to check the freq of the PeriodIndex too, given an empty PeriodIndex constructor needs a freq. Something like type(self)([], freq=self.freq, name=self.name). Are there cases for other subclasses of Index?
The text was updated successfully, but these errors were encountered:
PeriodIndex for sure has some of these types of issues (people have been slowly working there way thru). Almost all other construction is centrally done, but still possible for edge cases.
The constructors should almost always be
self._shallow_copy(....) (you can pass a new values as the first arg, the meta data will be propogated
I think this should return an empty PeriodIndex object, not an empty Index object.
This happens because if there is an empty set as a result of
difference
, the object doesn't check its type before creating an empty version of itself: https://github.com/pydata/pandas/blob/v0.16.0/pandas/core/index.py#L1360. Generally I've seen a better construction for that line betype(self)([])
.I'm happy to make this PR, although I'm not sure whether I'm missing something on the intention. If I'm not, should this be executed by adding something in Index's
difference
method, or overriding that method inPeriodIndex
?A method that removed items from the index would avoid any subclass-specific code, but the drop method also has some odd behavior:
So if you're creating a new object, you'd need to check the freq of the PeriodIndex too, given an empty PeriodIndex constructor needs a freq. Something like
type(self)([], freq=self.freq, name=self.name)
. Are there cases for other subclasses of Index?The text was updated successfully, but these errors were encountered: