我从 yahoo finance 下载了一个csv文件。
使用命令导入文件时,日期有问题:
pd_index=pd.read_csv("path/yahoo.csv",parse_dates=["Date"])
此命令的输出为:
Date Open ... Adj Close Volume
0 2018-03-12 25779.57031 ... 25826.42969 388480000
1 2018-04-12 25752.56055 ... 25027.07031 418900000
2 2018-06-12 24737.41992 ... 24947.66992 471690000
3 2018-07-12 24918.82031 ... 24388.94922 398230000
4 2018-10-12 24360.94922 ... 24423.25977 389690000
5 2018-11-12 24719.91016 ... 24370.24023 342960000
6 2018-12-12 24509.08984 ... 24527.26953 344330000
7 2018-12-13 24575.85938 ... 24597.38086 299970000
8 2018-12-14 24408.03906 ... 24100.50977 416940000
如您在输出中看到的,“日期”列的每个输出的“格式”为:
Date
0 2018-03-12 year-day-month
1 2018-04-12 year-day-month
2 2018-06-12 year-day-month
3 2018-07-12 year-day-month
4 2018-10-12 year-day-month
5 2018-11-12 year-day-month
6 2018-12-12 year-month-day
7 2018-12-13 year-month-day
8 2018-12-14 year-month-day
如您所见,由于第6行的顺序有所变化。我不明白为什么,因为在csv文件csv file from yahoo finance中,顺序始终是恒定的(日-月-年)
有人知道我在哪里犯了错误,为什么我的代码会这样反应?