在python中删除小于特定值的行 [英] Remove rows in python less than a certain value

查看:1727
本文介绍了在python中删除小于特定值的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得这个问题之前一定已经有人回答过,但是我在堆栈溢出时找不到答案!

I feel like this question must have been answered by someone before, but I can't find an answer on stack overflow!

我有一个看起来像这样的数据框result,我想删除所有小于或等于 10

I have a dataframe result that looks like this and I want to remove all the values less than or equal to 10

>>> result
                       Name              Value      Date
189                   Sall                19.0  11/14/15
191                     Sam               10.0  11/14/15
192                 Richard               21.0  11/14/15
193                  Ingrid                4.0  11/14/15 

此命令有效并删除所有10的值:

This command works and removes all the values that are 10:

df2 = result[result['Value'] != 10]

但是当我尝试添加< =限定词时,我收到错误消息SyntaxError: invalid syntax

But when I try to add the <= qualifier I get the error message SyntaxError: invalid syntax

df3 = result[result['Value'] ! <= 10]  

我觉得可能有一个非常简单的解决方案.预先感谢!

I feel like there is probably a really simple solution. Thanks in advance!

推荐答案

代替此

df3 = result[result['Value'] ! <= 10]  

使用

df3 = result[~(result['Value'] <= 10)]  

它将起作用. 或简单地使用

It will work. OR simply use

df3 = result[result['Value'] > 10]  

这篇关于在python中删除小于特定值的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆