import pandas as pd df = pd.read_json("cost.json",encoding="utf-8-sig") print(df) #1.print total money print('(1).total money=',df['支出金額'].sum()) #2.sort the money and print top 5 print('(2).sort the money and print top 5=', df.sort_values(by="支出金額",ascending=False).head(5)) #3.print out the record of cost > 200 #command: df[condition] = df[c1] #command: df[['column name1','column name2]] c1 = (df['支出金額'] > 200) print('(3).the record of cost > 200=', df[c1]) print(df[['支出金額','時間']][c1]) #4.print out the record which is transpotation c2 = (df['大項目']=='行') print('(4).the record which is transpotation',df[c2]) #5.print out the total cost which is transpotation c2 = (df['大項目']=='行') print('(5).the total cost which is transpotation=',df['支出金額'][c2].sum())