API: Index doesn't results in PeriodIndex if Period contains NaT by sinhrks · Pull Request #13664 · pandas-dev/pandas (original) (raw)
This improve Period
handling a little.
# this should be PeriodIndex
pd.Index([pd.Period('2011-01', freq='M'), pd.NaT])
# Index([2011-01, NaT], dtype='object')
# this should be object dtype
pd.Index([pd.Period('2011-01', freq='M'), pd.Period('2011-01-01', freq='D')])
# pandas._period.IncompatibleFrequency: Input has different freq=D from PeriodIndex(freq=M)
# this should be object dtype
pd.PeriodIndex(['2011-01', 'NaT'], freq='M').fillna(pd.Period('2011-01-01', freq='D'))
# pandas._period.IncompatibleFrequency: Input has different freq=D from PeriodIndex(freq=M)