AttributeError:“函数"对象在 pandas 中没有属性"bar" [英] AttributeError: 'function' object has no attribute 'bar' in pandas

查看:93
本文介绍了AttributeError:“函数"对象在 pandas 中没有属性"bar"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pandas数据框,它是如下所示的pandas数据框类型

I have a pandas data frame which is a pandas data frame type as shown below

type(df)

Out[176]:

pandas.core.frame.DataFrame

但是,当我尝试在此数据框上使用任何绘图功能(如条形图)时,会出现如下错误;

But when I try to use any plotting functions on this data frame like bar graph it gives an error as follows;

df.plot.bar()

AttributeError: 'function' object has no attribute 'bar'

其他功能(例如箱形图或历史记录)也无法正常工作.知道为什么吗?

Not other function like box plot or hist is also not working. Any idea why?

推荐答案

如果您想绘制特定的列,可以尝试: df.plot(x='x', y='y', kind='bar')

If you have specific columns in mind that you want to plot, you can try: df.plot(x='x', y='y', kind='bar')

这篇关于AttributeError:“函数"对象在 pandas 中没有属性"bar"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆