【问题标题】:Pandas filter rows of data frame where value is below 10 and greather then 1000 [duplicate]Pandas过滤值小于10且大于1000的数据帧行[重复]
【发布时间】:2021-09-30 16:16:15
【问题描述】:

我想删除 Área 低于 10 和高于 1000 的行。

所以这很完美:

x = dataset[(dataset['Área'] > 10) ]

但这不是:

x = dataset[(dataset['Área'] > 10) and (dataset['Área'] < 1000)]

请解释一下。我正在关注本教程here

谢谢。

【问题讨论】:

标签: python pandas


【解决方案1】:

这是因为and 是合乎逻辑的,即。 True and False 将产生 False。你需要按位与,即。 &amp;.

试试:

x = dataset[(dataset['Área'] > 10) & (dataset['Área'] < 1000)]

【讨论】:

    猜你喜欢
    • 2016-03-18
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-15
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    相关资源
    最近更新 更多