pythonpandasseries

How do I check if a specific item in pandas series is NaT


I have a series of random dates which have some NaT values in it (for example: index 112875)

DataFrame['series']
0        2006-06-06
1        2006-09-06
2        2006-12-22
3        2007-03-09
4        2007-06-05
            ...    
112871   2019-10-29
112872   2020-02-27
112873   2020-04-28
112874   2020-07-28
112875          NaT
Name: series, Length: 112876, dtype: datetime64[ns]

what I'm trying to figure out is when approaching a specific NaT value, to what should I compare it in order to get True?

IN  [5] DataFrame['series'][112875] == None
OUT [5] False

Solution

  • You can use: DataFrame['series'].str.contains('NaT')

    This gives True if row contains NaT