python循环读取csv文件变慢_实现读取csv文件,文件里面是有限个百分数成绩(99.6、76.8等等...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

实现读取csv文件,文件里面是有限个百分数成绩(99.6、76.8等等)导出GPA 和等级

==================================

代码是这样,但是报错了,在score = float(sc)这行就报错了,下面有没有错误还不知道,大佬能帮看看嘛?

错误代码:TypeError: 'float' object is not subscriptable

import pandas as pd

data = pd.read_csv("scores.csv")

grade = []

GPA = []

JD = (score-50)/10

GPA.append(JD)

sc = "%6.1f" % score

score = float(sc)

n = print(score)

for i in (1,n):

if score[i]>= 95:

grade = "A+"

elif score[i] >= 90:

grade = "A"

elif score[i] >= 85:

grade = "A-"

elif score[i] >= 82:

grade = "B+"

elif score[i] >= 78:

grade = "B"

elif score[i] >= 75:

grade = "B-"

elif score[i] >= 71:

grade = "C+"

elif score[i] >= 66:

grade = "C"

elif score[i] >= 62:

grade = "C-"

elif score[i] >= 60:

grade = "D"

else:

grade = "F"

grade.append(grade)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值