python-3.x - 如何比较熊猫数据框中的值
问题描述
说A是一个数据框,表示奥运会比赛中所有国家的数据。
我正在尝试打印所有具有最大值的国家/地区的数据:(summer_gold - winter_gold)/总黄金数。
请检查我的代码,让我在这里做错了什么。
def answer_three():
count=A['Gold'].count() + A['Gold.1'].count() #Gold is no. of summer gold & Gold.1 is winter gold
X=(((A['Gold']-A['Gold.1']).abs())/count).max()
Y=A.where(((A['Gold']-A['Gold.1'].abs())/count).max() == X)
return Y
answer_three()
我得到的错误是:
"Array conditional must be same shape as self"
解决方案
推荐阅读
- c# - c#连接字符串和连接app.config
- sql - 我可以只从文件备份中恢复 SQL Server 实例吗?
- java - 到 EJB 的远程连接在 localhost 上工作,但在 127.0.0.1 和另一台服务器上失败
- matlab - 调试时只针对特定的循环索引
- ios - 在 Xcode 项目中导入自定义静态库
- ionic-framework - Ionic 应用程序创建卡在“ionic start app_name tabs”
- angular - Angular:使用 HttpClient 的 RequestOptions 等价物
- c - `getrlimit()` 和 `setrlimit()` 是否通过读取和写入 `/etc/security/limits.conf` 来工作?
- c# - 在 Unity 中创建二维圆形网格
- mongodb - 如何使用 Meteor 更新数组