简体   繁体   中英

why I Can't drop NAN values with dropna() function in pandas

simple i make pandas data frame from dictionary then use dropna I dont know why its not removing NaN

df=pd.DataFrame(dic)
df.dropna(axis=1,inplace=True)
df.head()

带有代码的输出图像

my code link(not completed) https://colab.research.google.com/drive/1HoniG14dUZbERxDm9QKowjkpacK3wyt5?usp=sharing

You likely have "NaN" strings. You should first convert them to real NA values. Let's use pd.NA :

df = df.replace('NaN', pd.NA).dropna(axis=1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM