标签:end excel average temp sum nts row xlsx pen
import pandas as pd
students = pd.read_excel(‘D:/Temp/Students.xlsx‘,index_col=‘ID‘)
temp = students[[‘Test_1‘,‘Test_2‘,‘Test_3‘]]
row_sum = temp.sum(axis=1)
row_mean = temp.mean(axis=1)
students[‘Total‘] = row_sum
students[‘Average‘] = row_mean
col_mean=students[[‘Test_1‘,‘Test_2‘,‘Test_3‘,‘Total‘,‘Average‘]].mean() #python没有Aver 只有mean
col_mean[‘Name‘]=‘Sumary‘
students = students.append(col_mean,ignore_index = True) #忽略索引
print(students)
标签:end excel average temp sum nts row xlsx pen
原文地址:https://www.cnblogs.com/inserence/p/11061327.html