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

相关内容

热门资讯

复盘辅助挂!wejoker手机... 复盘辅助挂!wejoker手机版透视脚本,德扑之星怎么设置埋牌,都是真的有挂(有挂方法)1、每一步都...
玩家必看教程!xpoker辅助... 玩家必看教程!xpoker辅助神器,德州局怎么透视,切实是有挂(发现有挂)亲,关键说明,透视脚本安卓...
2026版复盘!wepoker... 2026版复盘!wepoker辅助工具,如何下载德普之星辅助软件,总是真的有挂(有挂技巧)1、下载好...
必备辅助推荐!来玩app破解,... 必备辅助推荐!来玩app破解,hhpoker怎么开透视,一直是真的有挂(有挂细节);小薇(辅助器软件...
最终!wepoker破解器有用... 最终!wepoker破解器有用吗,如何下载德普之星辅助软件,总是真的是有挂(有挂头条)1、用户打开应...
一秒答解!wepoker有什么... 一秒答解!wepoker有什么规律,xpoker辅助助手,都是有挂(揭秘有挂)1、用户打开应用后不用...
连日来!aapoker如何设置... 连日来!aapoker如何设置胜率,德普之星app安卓版破解版,本来存在有挂(有挂解惑)1、德普之星...
我来教教你!we poker辅... 我来教教你!we poker辅助器下载,hhpoker辅助挂是真的吗,一贯真的有挂(有挂方法)1、辅...
近年来!wpk透视辅助,德普之... 近年来!wpk透视辅助,德普之星辅助工具如何打开,原来是真的有挂(有挂猫腻)1、起透看视 德普之星辅...
无独有偶!wepoker插件辅... 无独有偶!wepoker插件辅助,德普辅助器怎么用,一贯存在有挂(有挂猫腻)1、玩家可以在德普辅助器...