python - 重新计算和更正numpy数组中的值
问题描述
我有一个 CSV 格式的数据集,作为二维数组导入:
game_id, player_score, rounds_played
0, 56, 30
0, 44, 30
1, 77, 26
1, 34, 26
2, 36, 23
2, 31, 23
在下一步中,我需要创建一个新数组,其中 player_score 需要与每场比赛中的 rounds_played 相对化,以估计单独查看分数时的性能。
在“for循环”中,我做了类似的事情,我计算了每个分数的“权重”,然后再次将因子乘以回合:
给定,30 是这个集合中的最大 rounds_played 值:
weight = (player_score * rounds_played) / 30
new_score = weight
然后我会将 new_score 附加到一个新数组中。
如果我有一个更大的二维数组,这可能会变得很慢。- 是否有更短、更直接的方法(可能在 numpy 中)来创建一个具有更正分数的新数组?
解决方案
推荐阅读
- node.js - 我可以在 Node 项目中使用 Nuget 包吗?
- file - 如何根据巧合解析添加特定字符的文件?
- php - PHP 7.0 - urlencode/urldecode 不是对称的
- php - laravel 查询生成器中的错误
- android - 如何将活动缩小到其内容的大小
- node.js - Dialogflow fullfilment代码在nodejs中使用twilio发送otp
- javascript - 如何摆脱HDMI?
- python - 如何在excel中写入不超过100万条来自python数据框的记录
- react-native - ReactNative/ReactJS 的浮动工具栏组件?
- javascript - 在选择时设置默认值