Pandas Dataframe 没有 Plot 功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37275790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 01:14:40  来源:igfitidea点击:

Pandas Dataframe has no Plot function

python-3.xpandasplot

提问by hansolo

I'm trying to call df.plot.scatter(...)as shown here, where dfis a pandas.Dataframeobject.

我想打电话给df.plot.scatter(...)如图所示这里,这里df是一个pandas.Dataframe对象。

But my IDE can't suggest any plot function when I initiate suggestions (though it can suggest other dataframemembers like fillna(), to_json()etc).

但我的IDE无法提出任何绘图功能,当我发起的建议(虽然它同时也意味着其他dataframe成员一样fillna()to_json()等等)。

If I anyway write df.plot.scatter(...)and run it, it gives error:

如果我无论如何编写df.plot.scatter(...)并运行它,它会给出错误:

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

I use python 3.4 on windows 7. My IDE is PyCharm. These are the imports:

我在 Windows 7 上使用 python 3.4。我的 IDE 是 PyCharm。这些是进口:

import pandas as pd
import matplotlib.pyplot as plt

Can it be about my python version, or maybe this function is removed from pandas API? Thanks in advance.

可能是关于我的 python 版本,或者这个函数可能是从 Pandas API 中删除的?提前致谢。

回答by jezrael

I think your pandasversion is older as 0.17.0.

我认为你的pandas版本比0.17.0.

See DataFrame.plot.scatter:

DataFrame.plot.scatter

New in version 0.17.0.

0.17.0 版中的新功能。

In older version you can use:

在旧版本中,您可以使用:

df.plot(kind='scatter')