GPA转换

输入GPA和对应学分,转换出 平均GPA、加权GPA、满绩点为4的加权GPA、百分制成绩

import pandas as pd
 
df = pd.read_excel(path)
rawScore = df['绩点']
weight = df['学分']
avgGPA = rawScore.mean()
# 转百分制
# rawScore = rawScore*10+50
total = rawScore.mul(weight)
weighted_avgGPA_5 = total.sum()/weight.sum()

# 满四阈值
rawScore[rawScore>4] = 4
total = rawScore.mul(weight)
weighted_avgGPA_4 = total.sum()/weight.sum()

avgGPA, weighted_avgGPA_5, weighted_avgGPA_4

你可能感兴趣的:(笔记,python,数据挖掘,数据分析)