Coding-表格操作

读取日期表格数据并显示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('plot.csv')

# 格式转为日期
df['date'] = pd.to_datetime(df['date'])
df.set_index('date', inplace=True)
#输入折线图数据
plt.plot(df.index,df["a2c"],label='a2c',linewidth=1,color='c',marker='',markerfacecolor='blue',markersize=5)
plt.xlabel("date")
#横坐标为物品编号
plt.ylabel('loss')
#纵坐标为各类指标
plt.title("")
#折线图的名称

#图例说明
plt.legend()
#显示网格
plt.grid()
#显示图像
plt.show()