Я не уверен, что мне чего-то не хватает с mathplotlib imshow ().
Ниже приведен пример кода, который я написал.Я новичок в Python.
I = pd.read_csv("D:\\Temp\\train.csv", header=None)
M = I.as_matrix()
im = M[1,1:]
im = im.reshape(28,28)
plt.imshow(im)
Я получаю следующую ошибку.
нужна помощь, как это исправить и лучший способ сделать это.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-277-628dc6c46325> in <module>()
3 im = M[1,1:]
4 im = im.reshape(28,28)
----> 5 plt.imshow(im)
C:\Users\mapppppp\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\pyplot.py in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, hold, data, **kwargs)
3156 filternorm=filternorm, filterrad=filterrad,
3157 imlim=imlim, resample=resample, url=url, data=data,
-> 3158 **kwargs)
3159 finally:
3160 ax._hold = washold
C:\Users\mapppppp\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\__init__.py in inner(ax, *args, **kwargs)
1890 warnings.warn(msg % (label_namer, func.__name__),
1891 RuntimeWarning, stacklevel=2)
-> 1892 return func(ax, *args, **kwargs)
1893 pre_doc = inner.__doc__
1894 if pre_doc is None:
C:\Users\mapppppp\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\axes\_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5116 resample=resample, **kwargs)
5117
-> 5118 im.set_data(X)
5119 im.set_alpha(alpha)
5120 if im.get_clip_path() is None:
C:\Users\mapppppp\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\image.py in set_data(self, A)
543 if (self._A.dtype != np.uint8 and
544 not np.can_cast(self._A.dtype, np.float)):
--> 545 raise TypeError("Image data can not convert to float")
546
547 if (self._A.ndim not in (2, 3) or
TypeError: Image data can not convert to float