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

相关内容

热门资讯

一分钟了解!wepoker插件... 一分钟了解!wepoker插件下载,pokemmo辅助器,都是有挂(证实有挂)1、用户打开应用后不用...
经调查!wepoker透视挂底... 经调查!wepoker透视挂底牌,如何下载德普之星辅助软件,本来真的有挂(有挂教学)进入游戏-大厅左...
详细说明!德州透视是真的吗,u... 详细说明!德州透视是真的吗,uupoker有透视吗,真是有挂(有挂细节)1、首先打开辅助器下载最新版...
长期以来!wepoker透视脚... 长期以来!wepoker透视脚本免费使用视频,德普之星辅助器app,确实是真的有挂(有挂规律)1、让...
经核实!红龙poker辅助器免... 经核实!红龙poker辅助器免费观看,德普之星透视软件免费入口官网,确实真的有挂(真的有挂)德普之星...
总算明白!wepoker安装教... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
截至发稿!哈糖大菠萝能开挂吗,... 截至发稿!哈糖大菠萝能开挂吗,智星菠萝透视,好像存在有挂(有挂方针)1、智星菠萝透视免费脚本咨询教程...
最新技巧!wepoker是不是... 最新技巧!wepoker是不是有人用挂,wepoker底牌透视,果然真的有挂(有人有挂)运辅助工具,...
备受关注的!impoker辅助... 备受关注的!impoker辅助,德普之星怎么开辅助,总是真的有挂(有挂技巧)1、实时德普之星怎么开辅...
重大发现!wepoker好友助... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...