简体   繁体   English

pandas 升级到 v 1.0.1 后 df.plot 失败

[英]df.plot fails after pandas upgrade to v 1.0.1

I was using pandas 0.23.4 and just upgraded to 1.0.1.我使用的是 Pandas 0.23.4,刚刚升级到 1.0.1。

I have a code which generated a dataframe and I would plot it as a stacked bar plot df.plot(kind='bar') and as an area plot df.plot.area() .我有一个生成数据框的代码,我将它绘制为堆积条形图df.plot(kind='bar')和面积图df.plot.area() It was working fine.它工作正常。 I decided to upgrade pandas and now neither of the plot commands work.我决定升级大熊猫,现在这两个绘图命令都不起作用。 Here is an example:下面是一个例子:

df=pd.DataFrame()
df["col1"]=[0.7,0.2,0.1,0.0]
df["col2"]=[0.1,0.5,0.2,0.2]
df['col3']=[0.1,0.0,0.1,0.8]
df.plot.area()

This gives the error TypeError: float() argument must be a string or a number, not '_NoValueType' .这给出了错误TypeError: float() argument must be a string or a number, not '_NoValueType'

I don't know how to fix this.我不知道如何解决这个问题。 I would appreciate any help.我将不胜感激任何帮助。

Thanks!谢谢!

EDIT: Full error message:编辑:完整的错误信息:

Traceback (most recent call last):

  File "<ipython-input-96-b436d7233c8a>", line 1, in <module>
    df.plot.area()

  File "C:\Users\Anaconda3\lib\site-packages\pandas\plotting\_core.py", line 1363, in area
return self(kind="area", x=x, y=y, **kwargs)

  File "C:\Users\Anaconda3\lib\site-packages\pandas\plotting\_core.py", line 847, in __call__
    return plot_backend.plot(data, kind=kind, **kwargs)

  File "C:\Users\Anaconda3\lib\site-packages\pandas\plotting\_matplotlib\__init__.py", line 61, in plot
plot_obj.generate()

  File "C:\Users\Anaconda3\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 262, in generate
self._setup_subplots()

  File "C:\Users\Anaconda3\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 321, in _setup_subplots
axes = fig.add_subplot(111)

  File "C:\Users\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1257, in add_subplot
 a = subplot_class_factory(projection_class)(self, *args, **kwargs)

  File "C:\Users\Anaconda3\lib\site-packages\matplotlib\axes\_subplots.py", line 74, in __init__
self.update_params()

  File "C:\Users\Anaconda3\lib\site-packages\matplotlib\axes\_subplots.py", line 136, in update_params
return_all=True)

  File "C:\Users\Anaconda3\lib\site-packages\matplotlib\gridspec.py", line 467, in get_position
fig_bottom = fig_bottoms[rows].min()

  File "C:\Users\Anaconda3\lib\site-packages\numpy\core\_methods.py", line 32, in _amin
return umr_minimum(a, axis, None, out, keepdims, initial)

TypeError: float() argument must be a string or a number, not '_NoValueType'

Okay, I rebooted my the computer and now everything works.好的,我重新启动了计算机,现在一切正常。 No idea what was wrong before!之前不知道怎么回事!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM