原表:
import pandas as pd
import numpy as np
e_file = pd.ExcelFile(r"D:\mycode\files\7月下旬入库表.xlsx")
data = e_file.parse('7月下旬入库表')
pt1 = pd.pivot_table(data, index=['销售商'], columns=['来源省份'], values=['入库量(吨)'], aggfunc=np.sum, margins=True)
print(pt1)
原表:
import pandas as pd
import numpy as np
e_file = pd.ExcelFile(r"D:\mycode\files\7月下旬入库表.xlsx")
data = e_file.parse('7月下旬入库表')
pt1 = pd.pivot_table(data, index=['销售商'], columns=['来源省份'], values=['入库量(吨)'], aggfunc=np.sum, margins=True)
print(pt1)