如何添加另一个条件来过滤csv数据

时间:2017-06-12 22:23:03

标签: python pandas

我的问题与这篇文章有关:

How to filter csv data by applying conditions on certain columns in python

我如何申请其他条件?例如,当Energy_Supply_per_capita>时,我想我只对阿尔巴尼亚和赞比亚感兴趣。 280和emissions_of_co2< 30?感谢

1 个答案:

答案 0 :(得分:1)

试试这个:

q = "Country_Area in ['Albania','Zambia'] "+\
    "and Energy_Supply_per_capita > 280 "+\
    "and emissions_of_co2 < 30"
df.query(q)
相关问题