如何删除在特定列中的值为NaN的Pandas DataFrame行

眉间皱痕 提交于 2020-08-12 05:13:32

问题:

I have this DataFrame and want only the records whose EPS column is not NaN : 我有这个DataFrame ,只想要EPS列不是NaN的记录:

>>> df
                 STK_ID  EPS  cash
STK_ID RPT_Date                   
601166 20111231  601166  NaN   NaN
600036 20111231  600036  NaN    12
600016 20111231  600016  4.3   NaN
601009 20111231  601009  NaN   NaN
601939 20111231  601939  2.5   NaN
000001 20111231  000001  NaN   NaN

...ie something like df.drop(....) to get this resulting dataframe: ...例如df.drop(....)类的东西来获取结果数据df.drop(....)

                  STK_ID  EPS  cash
STK_ID RPT_Date                   
600016 20111231  600016  4.3   NaN
601939 20111231  601939  2.5   NaN

How do I do that? 我怎么做?


解决方案:

参考一: https://stackoom.com/question/uHUE/如何删除在特定列中的值为NaN的Pandas-DataFrame行
参考二: https://oldbug.net/q/uHUE/How-to-drop-rows-of-Pandas-DataFrame-whose-value-in-a-certain-column-is-NaN
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!