按照成绩分组(分数上下浮动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怎么发冤家牌(辅助挂)总是真的是有挂(果真有挂辅助教程)1、每一步都需要思考...
今日头条!微扑克数据分析(辅助... 今日头条!微扑克数据分析(辅助挂)果然是真的有挂(存在有挂辅助app)1)免费钻石:进一步探索免费脚...
必备攻略!约局吧德州透视(辅助... 必备攻略!约局吧德州透视(辅助挂)切实有挂(有挂规律辅助脚本)1、在插件功能辅助器技巧中,中转单元十...
总算清楚!wpk辅助(辅助挂)... 总算清楚!wpk辅助(辅助挂)其实真的是有挂(有挂方式辅助器)该软件可以轻松地帮助玩家将外卦神器提升...
程序员教你!wepoker私人... 程序员教你!wepoker私人局俱乐部(辅助挂)确实存在有挂(有挂分享辅助方法)1、脚本辅助下载、免...
分享个大家!wepoker免费... 分享个大家!wepoker免费脚本咨询(辅助挂)切实是有挂(有挂存在辅助工具)能透视中分为三种模型:...
玩家亲测!wepoker轻量版... 玩家亲测!wepoker轻量版透视系统(辅助挂)一贯是有挂(有挂方式辅助工具)玩家亲测!wepoke...
记者发布!aapoker怎么拿... 记者发布!aapoker怎么拿好牌(辅助挂)一贯真的有挂(有挂头条辅助软件)1、首先打开辅助器下载最...
分享认知!wepoker辅助分... 分享认知!wepoker辅助分析器(辅助挂)真是真的有挂(确实有挂辅助软件)1、用户打开应用后不用登...
重大通报!wepoker手机版... 重大通报!wepoker手机版透视脚本(辅助挂)一直存在有挂(有挂神器辅助教程)1、上手简单,内置详...