操作环境是Anaconda
我的代码是
from sklearn.datasets import fetch_openml
from matplotlib import pyplot as plt
mnist = fetch_openml('mnist_784')
x,y = mnist [ "data"] , mnist ["target"]
print("MINST数据集大小为:{}".format(x.shape))
for i in range (25):
digit =x[i * 2500]
digit_image = digit.reshape (28,28)
plt.subplot(5,5, i +1)
plt.axis ( ' off')
plt.imshow (digit_image , cmap='gray ')
plt.show ()
报错
```python
MINST数据集大小为:(70000, 784)
Traceback (most recent call last):
File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3080, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Administrator\untitled3.py", line 21, in <module>
digit =x[i * 2500]
File "D:\Anaconda\lib\site-packages\pandas\core\frame.py", line 3024, in __getitem__
indexer = self.columns.get_loc(key)
File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3082, in get_loc
raise KeyError(key) from err
KeyError: 0
该怎么解决呀~