how to test if a variable is pd.NaT?

前端 未结 4 944
我寻月下人不归
我寻月下人不归 2020-12-14 14:01

I\'m trying to test if one of my variables is pd.NaT. I know it is NaT, and still it won\'t pass the test. As an example, the following code prints nothing :



        
4条回答
  •  时光取名叫无心
    2020-12-14 14:40

    If it's in a Series (e.g. DataFrame column) you can also use .isna():

    pd.Series(pd.NaT).isna()
    # 0    True
    # dtype: bool
    

提交回复
热议问题