我正在学习一个教程:https://youtu.be/PZkuTzeRE2U?t=682
然后我得到一个KeyError: 722
。
我试图找到在线含义,并且我的代码与本教程似乎相同。 我将添加更多代码,仅告诉我您需要查看和显示错误
我已经检查了一百次视频,并尝试搜索该错误代码,但是我无法找到任何实际答案。 我非常感谢您的帮助,因为我非常投入这项练习
问题似乎出在(price[end+1:end+16] - price[end])
if harmonics[j] == 1:
pips += 1000*(price[end+1:end+16] - price[end])
elif harmonics[j] == -1:
pips += 1000*(price[end] - price[end+1:end+16])
我希望条形图会出现,但是我得到了
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/AudioWorks/Documents/Coding and learning/Forex harmonics.py", line 58, in <module>
pips = 1000*(price[end+1:end+16] - price[end])
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 2927, in __getitem__
indexer = self.columns.get_loc(key)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\multi.py", line 2397, in get_loc
loc = self._get_level_indexer(key, level=0)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\multi.py", line 2652, in _get_level_indexer
code = level_index.get_loc(key)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 2659, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 722