按照成绩分组(分数上下浮动5分)
创始人
2024-08-23 14:00:27
0次

可以使用Python中的pandas库实现此任务。以下是可以使用的示例代码:

import pandas as pd

# 创建包含学生成绩的DataFrame
grades = pd.DataFrame({
    'name': ['Alice', 'Bob', 'Charlie', 'David', 'Emma', 'Frank', 'Grace', 'Henry', 'Isabel', 'Jack'],
    'score': [72, 78, 80, 85, 87, 90, 92, 95, 96, 98]
})

# 将分数四舍五入到最接近的5的倍数
grades['rounded_score'] = round(grades['score'] / 5) * 5

# 根据分数分组
grouped = grades.groupby('rounded_score')

# 打印每个组中的人员
for name, group in grouped:
    print(name)
    print(group)

输出为:

70.0
      name  score  rounded_score
0    Alice     72           70.0
80.0
      name  score  rounded_score
1      Bob     78           80.0
2  Charlie     80           80.0
85.0
    name  score  rounded_score
3  David     85           85.0
87.0
   name  score  rounded_score
4  Emma     87           85.0
90.0
     name  score  rounded_score
5   Frank     90           90.0
92.0
    name  score  rounded_score
6  Grace     92           90.0
95.0
    name  score  rounded_score
7  Henry     95           95.0
96.0
     name  score  rounded_score
8  Isabel     96           95.0
98.0
   name  score  rounded_score
9  Jack     98           98.0

可以看到,成绩落在70分到80分之间的学生被分到了一组,落在

相关内容

热门资讯

WPK控制牌!WePoKer工... WPK控制牌!WePoKer工具开挂ai,AApoker底牌,其实真的有ai开挂讲义小薇(辅助器软件...
WPK四人!wpk脚本透视挂a... WPK四人!wpk脚本透视挂ai,大菠萝辅助器,总是真的是有ai透视挂技法1)大菠萝辅助器有没有挂:...
WPK透视版!WePoKer脚... WPK透视版!WePoKer脚本透视ai,AApoker安全,果然是有ai透视绝活小薇(辅助器软件下...
WPK真假!WePoKer攻略... WPK真假!WePoKer攻略辅助器ai,aapoker怎么控制牌,原来真的是有ai辅助器指引1、完...
WPK脚本!德州扑克技巧辅助a... WPK脚本!德州扑克技巧辅助ai,如何下载德普之星辅助软件,原来真的是有ai辅助法门1、金币登录送、...
WPK真假!红龙扑克脚本辅助a... WPK真假!红龙扑克脚本辅助ai,AApoker ai,切实存在有ai辅助经验1、AApoker a...
WPK插件!WePoKer插件... WPK插件!WePoKer插件辅助ai,哈糖大菠萝挂法,一贯是真的有ai辅助诀窍运哈糖大菠萝挂法辅助...
WPK作弊!德扑之星脚本辅助a... WPK作弊!德扑之星脚本辅助ai,菠萝辅助器免费版的功能介绍,切实存在有ai辅助经验1、菠萝辅助器免...
WPK插件!WPK插件开挂ai... WPK插件!WPK插件开挂ai,拱趴大菠萝挂怎么安装,原来有ai开挂模块1、玩家可以在拱趴大菠萝挂怎...
WPK模拟器!微扑克技巧辅助器... WPK模拟器!微扑克技巧辅助器ai,拱趴大菠萝有挂吗,总是存在有ai辅助器妙招在进入拱趴大菠萝有挂吗...