ENH/BUG: Period/PeriodIndex supports NaT by sinhrks · Pull Request #7485 · pandas-dev/pandas (original) (raw)

I may misunderstand the point, but I intend to the PeriodIndex comparison to be compat with Timestamp/NaT behavior.

pd.NaT > pd.Timestamp('2011-01-01')
# False
pd.NaT < pd.Timestamp('2011-01-01')
# False

But I now found DatetimeIndex behaves oddly. Maybe the correct result is [False, False] if compared elemental-wise.

idx1 = pd.DatetimeIndex(['2011-01-01', pd.NaT], freq='M')
idx2 = pd.DatetimeIndex([pd.NaT, '2011-01-01'], freq='M')
print(idx1 > idx2)
# [True, False]