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
PeriodIndex w/ Series is allowed, PeriodIndex w/ DatetimeIndex is not. Is this intentional? If not, which should be made to match the other?
>>> dti = pd.date_range('2016-01-01', periods=3)
>>> ser = pd.Series(dti)
>>> pi = dti.to_period()
>>> ser - pi
0 0 days
1 0 days
2 0 days
dtype: timedelta64[ns]
>>> dti - pi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/core/indexes/datetimelike.py", line 724, in __sub__
typ2=type(other).__name__))
TypeError: cannot subtract DatetimeIndex and PeriodIndex
>>> pi - ser
0 0 days
1 0 days
2 0 days
dtype: timedelta64[ns]
>>> pi - dti
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/core/indexes/datetimelike.py", line 731, in __rsub__
return -(self - other)
File "pandas/core/indexes/datetimelike.py", line 724, in __sub__
typ2=type(other).__name__))
TypeError: cannot subtract DatetimeIndex and PeriodIndex
The text was updated successfully, but these errors were encountered:
It looks like this is caused by a line in ops._TimeOp._convert_to_array
elif inferred_type == 'integer':
# py3 compat where dtype is 'm' but is an integer
if values.dtype.kind == 'm':
values = values.astype('timedelta64[ns]')
elif isinstance(values, pd.PeriodIndex):
values = values.to_timestamp().to_series()
PeriodIndex
w/Series
is allowed,PeriodIndex
w/DatetimeIndex
is not. Is this intentional? If not, which should be made to match the other?The text was updated successfully, but these errors were encountered: