BUG: Series/Index contains NaT with object dtype comparison incorrect by sinhrks · Pull Request #13592 · pandas-dev/pandas (original) (raw)

Series and Index compares NaT == NaT as True if it has object dtype.

pd.Series([pd.NaT])
#0   NaT
# dtype: datetime64[ns]

# OK
pd.Series([pd.NaT]) == pd.NaT
#0    False
# dtype: bool

# NG in object dtype
pd.Series([pd.NaT], dtype=object) == pd.NaT
#0    True
# dtype: bool

# OK
pd.Index([pd.NaT]) == pd.NaT
array([False], dtype=bool)

# NG in object dtype
pd.Index([pd.NaT], dtype=object) == pd.NaT
# array([ True], dtype=bool)