我想在其中一列中删除所有NaN变量,但是当我使用 df.dropna(axis=0, inplace=True)
它删除了我的整个数据框架。为什么会发生这种情况?
我已经使用了两个 df.dropna
和 df.dropna(axis=0, inplace=True)
而且删除NaN也不行。
我正在对我的数据进行分选,这样我就可以运行一个高斯模型,但我不能对NaN变量进行分选,我想删除它们,但仍有我的数据框架来运行模型。
不知道你的情况如何,但分享一下在我的情况下有效的解决方案。
那些没有用的
df = df.dropna() #==> make the df empty.
df = df.dropna(axis=0, inplace=True) #==> make the df empty.
df.dropna(axis=0, inplace=True) #==> make the df empty.
奏效的是:
df.dropna(how='all',axis=0, inplace=True) #==> Worked very well...
感谢上面Anky的评论