qq_42110456 2022-04-19 14:51 采纳率: 0%
浏览 116

pandas和matplotlib一起使用进行画图,提示nonetype

问题遇到的现象和发生背景

pandas和matplotlib一起使用提示nonetype

问题相关代码,
import pandas
import seaborn
import  matplotlib.pyplot as code

speed = [0.1, 17.5, 40, 48, 52, 69, 88]
lifespan = [2, 8, 70, 1.5, 25, 12, 28]
index = ['snail', 'pig', 'elephant',
         'rabbit', 'giraffe', 'coyote', 'horse']
df = pandas.DataFrame([11,2,2],[2,3,4])
print(df)
seaborn.boxenplot(x=speed,y=lifespan)
code.bar(speed,lifespan)
code.show()


```勿粘贴截图 


###### 运行结果及报错内容 
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\getlimits.py", line 462, in __new__
    dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2021.3.2\plugins\python\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2021.3.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:/CODE/playwright/go.py", line 11, in <module>
    seaborn.boxenplot(x=speed,y=lifespan)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\_decorators.py", line 46, in inner_f
    return f(**kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\categorical.py", line 2642, in boxenplot
    plotter.plot(ax, kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\categorical.py", line 2065, in plot
    self.draw_letter_value_plot(ax, boxplot_kws)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\categorical.py", line 2061, in draw_letter_value_plot
    ax.autoscale_view(scalex=self.orient == "h", scaley=self.orient == "v")
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 2935, in autoscale_view
    handle_single_axis(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 2895, in handle_single_axis
    x0, x1 = locator.nonsingular(x0, x1)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\ticker.py", line 1654, in nonsingular
    return mtransforms.nonsingular(v0, v1, expander=.05)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\transforms.py", line 2880, in nonsingular
    if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\getlimits.py", line 465, in __new__
    dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable

###### 我的解答思路和尝试过的方法 
禁用pandas相关的语句就可以了
```python
import pandas
import seaborn
import  matplotlib.pyplot as code

speed = [0.1, 17.5, 40, 48, 52, 69, 88]
lifespan = [2, 8, 70, 1.5, 25, 12, 28]
index = ['snail', 'pig', 'elephant',
         'rabbit', 'giraffe', 'coyote', 'horse']
#df = pandas.DataFrame([11,2,2],[2,3,4])
#print(df)
seaborn.boxenplot(x=speed,y=lifespan)
code.bar(speed,lifespan)
code.show()

我想要达到的结果

使用pandas中的数据进行画图,直接使用数据或者间接使用数据均可以

  • 写回答

1条回答 默认 最新

  • keenanli 2022-04-19 15:12
    关注

    你的代码我运行是没有报错的。不知道是不是pandas版本的问题。我的pandas是1.4.1

    评论

报告相同问题?

问题事件

  • 创建了问题 4月19日

悬赏问题

  • ¥20 python忆阻器数字识别
  • ¥15 无法输出helloworld
  • ¥15 高通uboot 打印ubi init err 22
  • ¥20 PDF元数据中的XMP媒体管理属性
  • ¥15 R语言中lasso回归报错
  • ¥15 网站突然不能访问了,上午还好好的
  • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
  • ¥15 semrush,SEO,内嵌网站,api
  • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
  • ¥15 振荡电路,ADS仿真