我有一個(gè)用 pandas 導(dǎo)入的數(shù)據(jù)框。 Open High Low Close VolumeDate 2020-10-09 115.2800 117.0000 114.9200 116.9700 995446002020-10-08 116.2500 116.4000 114.5901 114.9700 834771502020-10-07 114.6200 115.5500 114.1300 115.0800 968489902020-10-06 115.7000 116.1200 112.2500 113.1600 1614982002020-10-05 113.9100 116.6500 113.5500 116.5000 106243800 ... ... ... ... ...2010-10-15 10.9800 11.2500 10.8896 11.2407 9167571532010-10-14 10.7746 10.8025 10.7286 10.7968 4332586672010-10-13 10.7214 10.7843 10.7071 10.7193 6210621522010-10-12 10.5504 10.6964 10.4461 10.6621 5564510572010-10-11 10.5264 10.6157 10.5214 10.5486 426705269我在嘗試引用專欄時(shí)遇到困難。我認(rèn)為它應(yīng)該像這樣簡(jiǎn)單dataset['Close']。然而每當(dāng)我嘗試這個(gè)時(shí),我都會(huì)得到KeyError: 'Close'。我用來創(chuàng)建數(shù)據(jù)集的確切行是dataset = pd.read_csv('AAPL.csv', index_col="Date", parse_dates=True)根據(jù)要求 AAPL.csv(前幾行):Date, Open, High, Low, Close, Volume10/09/2020,115.28,117,114.92,116.97,9954460010/08/2020,116.25,116.4,114.5901,114.97,8347715010/07/2020,114.62,115.55,114.13,115.08,96848990
1 回答

蕪湖不蕪
TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超7個(gè)贊
使用print(dataset.columns.tolist())
后發(fā)現(xiàn)名字中確實(shí)有空格。通過重新格式化源文件來修復(fù)。
添加回答
舉報(bào)
0/150
提交
取消