Date D1 D2 D3
01/01/2017 1013 1013 1013
02/01/2017 1014 1013.5 1015
03/01/2017 1014 1014.5 1014
04/01/2017 1014 1014 1012.4
05/01/2017 1014 1013.5 1012
06/01/2017 1014 1014 1012
07/01/2017 1012 1013 1011.8
08/01/2017 1012 1012 1011.8
09/01/2017 1011 1011 1012
10/01/2017 1012 1012 1013.6
11/01/2017 1012 1013 1014
12/01/2017 1013 1013 1013
13/01/2017 1013 1013 1013
14/01/2017 1012 1012.5 1012
15/01/2017 1014.5 1012 1015
16/01/2017 1014 1014 1015.9
17/01/2017 1015 1015 1015.4
18/01/2017 1015 1014 1015.6
19/01/2017 1014 1014 1015
20/01/2017 1014 1013 1015.3
21/01/2017 1014 1014 1014
22/01/2017 1014 1013 1016
23/01/2017 1014 1013 1016
24/01/2017 1014 1013 1016
25/01/2017 1014 1014 1015
26/01/2017 1014 1014 1014.7
27/01/2017 1014 1013 1013.5
28/01/2017 1013 1012 1013.4
29/01/2017 1012 1013 1014
30/01/2017 1012 1014 1014.5
31/01/2017 1014 1013 1014
01/02/2017 1014 1014 1012
02/02/2017 1014 1013 1014
03/02/2017 1014 1016 1013
04/02/2017 1014 1014 1015
05/02/2017 1014 1013 1013
06/02/2017 1013 1013 1014
07/02/2017 1015 1014 1013
08/02/2017 1014 1014 1015
09/02/2017 1014 1013 1014
10/02/2017 1014 1013 1013
11/02/2017 1014 1013 1013
12/02/2017 1013 1014 1014
13/02/2017 1013 1014 1014
14/02/2017 1016 1015.5 1015.6
15/02/2017 1016 1015.5 1015
16/02/2017 1016 1015 1012
17/02/2017 1016 1016 1011.9
18/02/2017 1014 1016 1012.3
19/02/2017 1015 1013 1013.4
20/02/2017 1015 1016 1012.3
21/02/2017 1014 1015 1010.7
22/02/2017 1012 1013 1010.7
23/02/2017 1013 1013 1013.2
24/02/2017 1014 1013 1013.2
25/02/2017 1013 1013 1014
26/02/2017 1014 1014 1014.5
27/02/2017 1013 1013 1011.3
28/02/2017 1012 1013 1012.6
这是我用于绘制上述数据的最小样本代码
df = pd.read_csv(data_path, index_col=0, parse_dates=True)
df1 = df[['D1', 'D2', 'D3']]
plt1 = df1.plot(marker='o', figsize=(16, 9), title=title, grid=True)
这是我得到的奇怪的情节: -
情节在开始时被淹没,甚至没有。
DD中的日期格式:MM:YYYY已变为完全不同。
有人可以指导我解决上述问题吗?
答案 0 :(得分:3)
将参数dayfirst=True
用于pd.read_csv
df = pd.read_csv(data_path, index_col=0, parse_dates=True, dayfirst=True)
df1 = df[['D1', 'D2', 'D3']]
plt1 = df1.plot(marker='o', figsize=(16, 9), title=title, grid=True)