按照成绩分组(分数上下浮动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分之间的学生被分到了一组,落在

相关内容

热门资讯

八分钟辅助!aapoker破解... 八分钟辅助!aapoker破解侠是真的吗,aapoker怎么设置提高好牌几率,窍门教程(有挂透视)1...
第五分钟辅助!wepoker数... 第五分钟辅助!wepoker数据分析,wpk有那种辅助吗,练习教程(有挂细节)1、玩家可以在wpk有...
4分钟辅助!hhpoker辅助... 4分钟辅助!hhpoker辅助挂下载,hhpoker德州牛仔视频,诀窍教程(有挂神器)1、hhpok...
第3分钟辅助!wepoker祈... 第3分钟辅助!wepoker祈福有用吗,pokeplus脚本,绝活儿教程(真的有挂)1、起透看视 w...
第六分钟辅助!werplan脚... 第六分钟辅助!werplan脚本,aapoker怎么控制牌,技法教程(真的有挂)aapoker怎么控...
第六分钟辅助!德普之星怎么开辅... 第六分钟辅助!德普之星怎么开辅助,德州局脚本,讲义教程(有挂教学)亲,关键说明,德普之星怎么开辅助透...
一分钟辅助!hhpoker是真... 一分钟辅助!hhpoker是真的还是假的,红龙poker辅助平台,方式教程(有挂秘籍)1、hhpok...
第三分钟辅助!哈糖大菠萝万能挂... 第三分钟辅助!哈糖大菠萝万能挂,hhpoker的辅助是真的吗,资料教程(有挂方式)1、hhpoker...
6分钟辅助!wepoker透视... 6分钟辅助!wepoker透视有没有,wepokerplus万能挂,步骤教程(真的有挂)一、wepo...
第8分钟辅助!wepoker辅... 第8分钟辅助!wepoker辅助器是真的吗,wepoker透视脚本免费app,指引教程(真是有挂)1...