Closed
Description
Hello, I'm a new hand in data processing. I made an error when trying to draw with mplfinance (I think the error is probably caused by my own ignorance, but I tried for 3 hours and couldn't solve it)hope the boss can see where my error is.
I tried to process the data. This is my data
Open High Low Close Volume
Date
2021-07-13 5400 5401 5396 5397 11544
2021-07-13 5396 5400 5396 5397 12050
2021-07-13 5398 5399 5397 5398 7252
2021-07-13 5398 5401 5397 5398 15682
2021-07-13 5399 5401 5398 5400 7292
2021-07-13 5400 5402 5399 5399 20944
2021-07-13 5399 5400 5398 5399 4174
2021-07-13 5399 5400 5397 5398 5318
2021-07-13 5398 5399 5397 5398 3340
2021-07-13 5399 5400 5393 5393 5508
2021-07-13 5392 5394 5387 5393 6362
2021-07-13 5393 5394 5390 5394 5042
2021-07-13 5394 5395 5393 5395 3320
2021-07-13 5394 5398 5393 5395 2148
2021-07-13 5395 5395 5392 5393 3310
2021-07-13 5394 5395 5391 5391 2812
2021-07-13 5392 5392 5388 5389 3020
2021-07-13 5388 5391 5386 5391 6956
2021-07-13 5389 5391 5389 5390 1944
2021-07-13 5390 5394 5388 5393 2250
2021-07-13 5392 5393 5391 5393 2134
2021-07-13 5393 5394 5390 5390 4602
This is print(df.axes)
[DatetimeIndex(['2021-07-13', '2021-07-13', '2021-07-13', '2021-07-13',
'2021-07-13', '2021-07-13', '2021-07-13', '2021-07-13',
'2021-07-13', '2021-07-13', '2021-07-13', '2021-07-13',
'2021-07-13', '2021-07-13', '2021-07-13', '2021-07-13',
'2021-07-13', '2021-07-13', '2021-07-13', '2021-07-13',
'2021-07-13', '2021-07-13', '2021-07-13'],
dtype='datetime64[ns]', name='Date', freq=None), Index([' Open', ' High', ' Low', ' Close', ' Volume'], dtype='object')]
This is the result of my attempt to draw
Traceback (most recent call last):
File "D:\Program\IDE\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3361, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Open'
File "d:\File\workspace\VS_workspace\Python_workspace\project_K\main.py", line 28, in <module>
mpf.plot(df)
File "D:\Program\IDE\Anaconda\lib\site-packages\mplfinance\plotting.py", line 301, in plot
dates,opens,highs,lows,closes,volumes = _check_and_prepare_data(data, config)
File "D:\Program\IDE\Anaconda\lib\site-packages\mplfinance\_arg_validators.py", line 63, in _check_and_prepare_data
opens = data[o].values
File "D:\Program\IDE\Anaconda\lib\site-packages\pandas\core\frame.py", line 3458, in __getitem__
indexer = self.columns.get_loc(key) File "D:\Program\IDE\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3363, in get_loc
raise KeyError(key) from err
KeyError: 'Open'