加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 删除列值<0的Pandas DataFrame行

发布时间:2020-12-20 12:40:54 所属栏目:Python 来源:网络整理
导读:我已经在 this线程中阅读了答案,但它没有回答我的确切问题. 我的DataFrame看起来像这样 Lady in the Water The Night Listener Just My Luck CorrelationClaudia Puig NaN 4.5 3.0 0.893405Gene Seymour 3.0 3.0 1.5 0.381246Jack Matthews 3.0 3.0 NaN 0.66
我已经在 this线程中阅读了答案,但它没有回答我的确切问题.
我的DataFrame看起来像这样

Lady in the Water  The Night Listener  Just My Luck  Correlation
Claudia Puig                    NaN                 4.5           3.0     0.893405
Gene Seymour                    3.0                 3.0           1.5     0.381246
Jack Matthews                   3.0                 3.0           NaN     0.662849
Lisa Rose                       2.5                 3.0           3.0     0.991241
Michael Phillips                2.5                 4.0           NaN    -1.000000
Mick LaSalle                    3.0                 3.0           2.0     0.924473

我想删除Michael Phillips的行,因为他的相关值低于零.
如上所述,我尝试了df = df [df.Correlation]和df = df.drop()的不同组合,但找不到任何有用的东西.

解决方法

df = df[df['Correlation'] >= 0]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读