Resampling with NaT in PeriodIndex raises ValueError · Issue #13224 · pandas-dev/pandas (original) (raw)
PeriodIndex
can't handle NaT
:
In [2]: pi = pd.PeriodIndex(['1970-01-01 00:00:00', pd.NaT, '1970-01-01 00:00:02'], freq='S')
In [3]: pd.DataFrame([2, 3, 5], pi).resample('1s').mean()
...
ValueError: Start and end must not be NaT
But DatetimeIndex
obtained from PeriodIndex
can:
In [4]: pd.DataFrame([2, 3, 5], pi.to_datetime()).resample('1s').mean()
Out[4]:
0
1970-01-01 00:00:00 2.0
1970-01-01 00:00:01 NaN
1970-01-01 00:00:02 5.0
Shouldn't these behave the same?
Versions:
python: 2.7.11.final.0
OS: Linux
machine: x86_64
pandas: 0.18.1+38.gc7e6f5f.dirty
numpy: 1.10.2