【问题标题】:Using Pandas how to find the count of values that satisfies a condtn?使用 Pandas 如何找到满足条件的值的计数?
【发布时间】:2021-06-19 18:52:09
【问题描述】:

给定的数据集没有列,问题是要找到 “有多少国家的 GDP 高于英国的 GDP?”

df=pd.DataFrame(columns=['S.No','Country','Population','Land_area','Median_Age','GDP','GDP_per_capita'])

我刚开始使用python并想出了查找英国GDP的代码,但不知道如何将其与GDP列的其他值进行比较

df2[df2.Country=='United Kingdom']["GDP"]

【问题讨论】:

    标签: python pandas dataset


    【解决方案1】:

    如果你正在寻找平等,你可以这样做:

    uk_gdp = df2[df2.Country=='United Kingdom']["GDP"]
    df2[df2["GDP"] == uk_gdp]
    

    【讨论】:

      猜你喜欢
      • 2019-07-15
      • 2019-03-11
      • 2018-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多