nat = np.datetime64(\'NaT\')
nat == nat
>> FutureWarning: In the future, \'NAT == x\' and \'x == NAT\' will always be False.
np.isnan(nat)
>> TypeError:
Very simple and surprisingly fast: (without numpy or pandas)
str( myDate ) == 'NaT' # True if myDate is NaT
Ok, it's a little nasty, but given the ambiguity surrounding 'NaT' it does the job nicely.
It's also useful when comparing two dates either of which might be NaT as follows:
str( date1 ) == str( date1 ) # True
str( date1 ) == str( NaT ) # False
str( NaT ) == str( date1 ) # False
wait for it...
str( NaT ) == str( Nat ) # True (hooray!)