Python Jupyter笔记本tensorflow打印错误

Python Jupyter笔记本tensorflow打印错误,python,pandas,dataframe,tensorflow,matplotlib,Python,Pandas,Dataframe,Tensorflow,Matplotlib,我试着浓缩2个数据帧,第一个是X,数字从1到112 x_data = np.arange(1,113,1) x_df = pd.DataFrame(data=x_data,columns = ['X']) 第二个是5月2日至10月2日的黄金价格,从: 在我使用 my_data = pd.concat([x_df,emas_df],axis=1) 数据是这样的 我想从我的_数据中绘制50个样本,并用“X”作为X,用“Terakhir”(在我的语言中是最后一个价格)作为y分散它 my_dat

我试着浓缩2个数据帧,第一个是X,数字从1到112

x_data = np.arange(1,113,1)
x_df = pd.DataFrame(data=x_data,columns = ['X'])
第二个是5月2日至10月2日的黄金价格,从:

在我使用

my_data = pd.concat([x_df,emas_df],axis=1)
数据是这样的

我想从我的_数据中绘制50个样本,并用“X”作为X,用“Terakhir”(在我的语言中是最后一个价格)作为y分散它

my_data.sample(n=50).plot(kind='scatter',x='X',y='Terakhir')
我犯了一个错误

ValueError                                Traceback (most recent call last)
<ipython-input-71-ca1cd423cab6> in <module>
----> 1 my_data.sample(n=50).plot(kind='scatter',x='X',y='Terakhir')

c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site-packages\pandas\plotting\_core.py in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   2625                           fontsize=fontsize, colormap=colormap, table=table,
   2626                           yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 2627                           sort_columns=sort_columns, **kwds)
   2628     __call__.__doc__ = plot_frame.__doc__
   2629 

c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site-packages\pandas\plotting\_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   1867                  yerr=yerr, xerr=xerr,
   1868                  secondary_y=secondary_y, sort_columns=sort_columns,
-> 1869                  **kwds)
   1870 
   1871 

c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site-packages\pandas\plotting\_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
   1650         if isinstance(data, DataFrame):
   1651             plot_obj = klass(data, x=x, y=y, subplots=subplots, ax=ax,
-> 1652                              kind=kind, **kwds)
   1653         else:
   1654             raise ValueError("plot kind %r can only be used for data frames"

c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site-packages\pandas\plotting\_core.py in __init__(self, data, x, y, s, c, **kwargs)
    808             # the handling of this argument later
    809             s = 20
--> 810         super(ScatterPlot, self).__init__(data, x, y, s=s, **kwargs)
    811         if is_integer(c) and not self.data.columns.holds_integer():
    812             c = self.data.columns[c]

c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site-packages\pandas\plotting\_core.py in __init__(self, data, x, y, **kwargs)
    785             raise ValueError(self._kind + ' requires x column to be numeric')
    786         if len(self.data[y]._get_numeric_data()) == 0:
--> 787             raise ValueError(self._kind + ' requires y column to be numeric')
    788 
    789         self.x = x

ValueError: scatter requires y column to be numeric
ValueError回溯(最近一次调用)
在里面
---->1我的数据.样本(n=50).绘图(种类class='scatter',x='x',y='Terakhir')
c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site packages\pandas\plotting\\u core.py in\uuuuuuuu call\uuuuuuu(self、x、y、kind、ax、subplot、sharex、sharey、layout、figsize、use\u索引、标题、网格、图例、样式、logx、logy、loglog、xticks、yticks、xlim、ylim、rot、fontsize、colormap、table、yerr、xerr、secondary\uy、sort列、kwds)
2625 fontsize=fontsize,colormap=colormap,table=table,
2626 yerr=yerr,xerr=xerr,secondary_y=secondary_y,
->2627排序列=排序列,**kwds)
2628 uuuu调用uuuu文件uuuuu=绘图uuu框架.uuuuuuuu文件__
2629
c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site packages\pandas\plotting\\u core.py在plot\u框架中(数据、x、y、种类、ax、子地块、sharex、sharey、布局、figsize、使用索引、标题、网格、图例、样式、logx、逻辑、日志、xticks、yticks、xlim、ylim、rot、fontsize、彩色地图、表格、yerr、xer、secondary\y、sort\u列、**kwd)
1867年,耶尔=耶尔,谢尔=谢尔,
1868 secondary_y=secondary_y,sort_columns=sort_columns,
->1869**科威特第纳尔)
1870
1871
c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site packages\pandas\plotting\u core.py in\u plot(数据、x、y、子地块、ax、种类、**kwds)
1650如果存在(数据、数据帧):
1651绘图对象=klass(数据,x=x,y=y,子地块=子地块,ax=ax,
->1652种类=种类,**科威特第纳尔)
1653其他:
1654 raise VALUE ERROR(“绘图类型%r只能用于数据帧”
c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site packages\pandas\plotting\\u core.py in\uuuuuuuu init\uuuuuuu(self、data、x、y、s、c、**kwargs)
808#稍后再处理这个论点
809s=20
-->810 super(散点图,自).\uuuuu init\uuuuuuu(数据,x,y,s=s,**kwargs)
811如果是整数(c),而不是self.data.columns.holds\u integer():
812 c=self.data.columns[c]
c:\users\tila\anaconda3\envs\tfdeeplearning\lib\site packages\pandas\plotting\\u core.py in\uuuuuuuu init\uuuuuu(self、data、x、y、**kwargs)
785提升值错误(self._kind+'要求x列为数字')
786如果len(self.data[y]。\u get\u numeric\u data())==0:
-->787提升值错误(self._kind+'要求y列为数字')
788
789 self.x=x
ValueError:散布要求y列为数字
我需要做些什么才能将X和Y分散到相应的列中?

“Terakhir”系列属于字符串数据类型,并且每个序列中都有一个逗号

执行以下操作以删除逗号,并将其转换为数字数据类型:

最后,绘制它!


如错误所述-只需检查“y='Terakhir'”其中“Terakhir”应该是数字数据类型。它似乎没有被算作数字,但所有数据都用数字填充。因此,我真的不知道是什么原因导致数据不被视为数字,也不知道如何将这些非数字转换为int/float。在这种情况下,共享所有列的少数记录,还显示我的_数据的输出fo()好了,这张图片已经编辑好了,现在在帖子上,Sir为你发布了一个详细的答案。TC@Tartila Sahid甚至不只是回答,你甚至给出了错误发生的详细和全面的原因!我非常感谢你的帮助,先生,如果有机会,你能再帮我一次吗?我在基于t的回归上有困难他的数据在。谢谢你的时间