Python Pandas figsize 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23762238/
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-13 22:04:17  来源:igfitidea点击:

Python Pandas figsize not defined

pythonpandasdata-analysis

提问by wuha

I am new to pandas for data analysis and I just installed pandas with required dependencies (NumPy, python-dateutil, pytz, numexpr, bottleneck and matplotlib). But when I started trying the most basic code:

我是 Pandas 的新手进行数据分析,我刚刚安装了具有所需依赖项(NumPy、python-dateutil、pytz、numexpr、bottleneck 和 matplotlib)的 Pandas。但是当我开始尝试最基本的代码时:

import pandas as pd
pd.set_option('display.mpl_style', 'default') # Make the graphs a bit prettier
figsize(15, 5)

It complains NameError: name 'figsize' is not defined.

它抱怨 NameError: name 'figsize' is not defined。

I am not sure if I still need some other dependencies. Could anyone shed some light on this?

我不确定是否还需要其他一些依赖项。任何人都可以对此有所了解吗?

回答by Padraic Cunningham

Try using %pylabif %pylab inlinedoes not work.

尝试使用%pylabif %pylab inline不起作用。

So it should be:

所以应该是:

 %pylab
 import pandas as pd
 pd.set_option('display.mpl_style', 'default') # Make the graphs a bit prettier
 figsize(15, 5)

The example is based on running the code in Ipython using Ipython magic command %pylabwhich gives you:

该示例基于使用 Ipython 魔术命令在 Ipython 中运行代码,该命令%pylab为您提供:

In [16]: %pylab
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib

If you are not using Ipython and the %pylabmagic you will have to use something like:

如果你没有使用 Ipython 和%pylab魔法,你将不得不使用类似的东西:

from pylab import *
rcParams['figure.figsize'] = 15,5

If you have Ipython-notebook istalled you can start it with pylab inline using:

如果您安装了 Ipython-notebook,您可以使用 pylab 内联方式启动它:

ipython notebook --pylab inline from the command line.

I would recommend using Ipython to start with.

我建议使用 Ipython 开始。

This is a link to the Ipython commands quick reference

这是 Ipython 命令快速参考的链接

回答by koliyat9811

When I got the same problem I changed figsize() from function call to assignment figsize = (15,5)
And it worked for me.

当我遇到同样的问题时,我将 figsize() 从函数调用更改为赋值 figsize = (15,5)
并且它对我有用。

回答by Guido van Steen

You might be using an earlier version of pandas. The function figsize()may have been introduced in a later version.

您可能使用的是早期版本的Pandas。该功能figsize()可能已在更高版本中引入。

In version 1.13 I achieved something similar with a statement like df.plot(figsize=(15, 5))

在 1.13 版中,我用类似的语句实现了类似的功能 df.plot(figsize=(15, 5))

回答by Mohammad Heydari

using VarianleName.plot(figszie=(n,n)will solve the problem n,ncould be numberslike 15,10Using Plot Figure Size

使用VarianleName.plot(figszie=(n,n)将解决问题 n,n可能numbers就像15,10使用绘图尺寸