ENH: Period ops NaT & timedelta ops · Issue #5202 · pandas-dev/pandas (original) (raw)

see related #5200, #4551, #4056

seem that a direct subtraction of PeriodIndexes would accomplish this,
but don't seem to support those types of ops...

This is currently an intersection (with a '-'), but want to do a timedelta like op

In [40]: pd.PeriodIndex(start='20130101',end='20130501',freq='M').sub(
pd.PeriodIndex(start='20130201',end='20130401',freq='M'))

Partially supported actuallly

In [5]:  pd.PeriodIndex(start='20130101',end='20130501',freq='M').to_series()-pd.PeriodIndex(start='20130205',end='20130405',freq='M').to_series()
Out[5]: 
2013-01   NaN
2013-02     0
2013-03     0
2013-04     0
2013-05   NaN
Freq: M, dtype: float64

In [6]:  pd.PeriodIndex(start='20130101',end='20130201',freq='B').to_series()-pd.Period('20130101',freq='B')

TypeError: unsupported operand type(s) for -: 'int' and 'Period'