Numpy: Checking if a value is NaT

前端 未结 6 1660
余生分开走
余生分开走 2020-12-23 21:12
nat = np.datetime64(\'NaT\')
nat == nat
>> FutureWarning: In the future, \'NAT == x\' and \'x == NAT\' will always be False.

np.isnan(nat)
>> TypeError:         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 22:07

    Another way would be to catch the exeption:

    def is_nat(npdatetime):
        try:
            npdatetime.strftime('%x')
            return False
        except:
            return True
    

提交回复
热议问题