Traceback (most recent call last):
File "C:PythonPython37libsite-packagespandascoreindexesase.py", line 3080, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libsindex.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libsindex.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libshashtable_class_helper.pxi", line 1625, in pandas._libs.hashtable.Int64HashTable.get_item
File "pandas\_libshashtable_class_helper.pxi", line 1632, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 20
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersmuhDesktopRollercoinBot-masterot.py", line 232, in <module>
main()
File "C:UsersmuhDesktopRollercoinBot-masterot.py", line 226, in main
bot().play()
File "C:UsersmuhDesktopRollercoinBot-masterot.py", line 161, in play
self.get_coin_fields()
File "C:UsersmuhDesktopRollercoinBot-masterot.py", line 177, in get_coin_fields
self.coin_pos.append(matches['BBox'][i])
File "C:PythonPython37libsite-packagespandascoreseries.py", line 824, in __getitem__
return self._get_value(key)
File "C:PythonPython37libsite-packagespandascoreseries.py", line 932, in _get_value
loc = self.index.get_loc(label)
File "C:PythonPython37libsite-packagespandascoreindexesase.py", line 3082, in get_loc
raise KeyError(key) from err
KeyError: 20
I cant solve this problem. I spent a lot of time on this and now I gave up. I made a bot. I did it for the convenience of me as I do not want to spend time on the site. It works fine on the first try but when the code loops I get an error like this.
def get_coin_fields(self):
screen = cv2.imread(screen_grab())
matches = matchTemplates(
[("card", cv2.imread("rc_items/coinflip_back.png"))],
screen,
N_object=float("inf"),
score_threshold=0.5,
#maxOverlap=0.25,
searchBox=None)
for i in range(len(matches['BBox'])):
self.coin_pos.append(matches['BBox'][i])
question from:
https://stackoverflow.com/questions/66060976/some-problems-in-python-pandas-and-keyerror 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…