import pandas as pd
import numpy as np
e_file = pd.ExcelFile(r'C:/Users/13375/Desktop/python/成绩表.xlsx')
data = e_file.parse('2020年成绩单')
# print(data)
# print('--'*20)
# pt1 = pd.pivot_table(data, index=['age'],columns=['math'],values=['score'],aggfunc=np.sum,margins=True)
# pd.set_option('display.max_columns',None) #显示所有的列
# print(pt1)
# ------------------------
pt2 = pd.pivot_table(data, index=['age'],columns=['math'],values=['score'],aggfunc=np.size,margins=True)
print(pt2)