import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams[‘font.sans-serif’] = [‘SimHei’] # pyplot中文显示
df = pd.read_csv(‘data.csv’, encoding=‘cp936’)
df = df.dropna() # 读取数据,丢弃缺失值
plt.figure()
df.plot(x=‘日期’)
plt.savefig(r’E:\first.jpg’)
plt.figure()
df1 = df[:]
df1[‘month’] = df1[‘日期’].map(lambda x: x[:x.rindex(’-’)])
df1 = df1.groupby(by=‘month’, as_index=False).sum()
df1.plot(x=‘month’, kind=‘bar’)
plt.savefig(r’E:\second.jpg’)