Checking if particular value (in cell) is NaN in pandas DataFrame not working using ix or iloc

后端 未结 3 1923
长情又很酷
长情又很酷 2020-12-09 01:13

Lets say I have following pandas DataFrame:

import pandas as pd
df = pd.DataFrame({\"A\":[1,pd.np.nan,2], \"B\":[5,6,0]})
         


        
3条回答
  •  借酒劲吻你
    2020-12-09 01:37

    Try this:

    In [107]: pd.isnull(df.iloc[1,0])
    Out[107]: True
    

    UPDATE: in a newer Pandas versions use pd.isna():

    In [7]: pd.isna(df.iloc[1,0])
    Out[7]: True
    

提交回复
热议问题