本文介绍了numpy:检查值是否为NaT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
nat = np.datetime64('NaT')
nat == nat
>> FutureWarning: In the future, 'NAT == x' and 'x == NAT' will always be False.
np.isnan(nat)
>> TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
如何检查datetime64是否为NaT?我似乎无法从文档中挖掘任何东西.我知道Pandas可以做到,但我不希望对如此基本的东西添加依赖.
How can I check if a datetime64 is NaT? I can't seem to dig anything out of the docs. I know Pandas can do it, but I'd rather not add a dependency for something so basic.
推荐答案
As MSeifert mentioned, Numpy contains
isnat
function since version 1.13. 这篇关于numpy:检查值是否为NaT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!