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:
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.
I am not sure if I still need some other dependencies. Could anyone shed some light on this?
Try using %pylab
if %pylab inline
does not work.
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 %pylab
which gives you:
In [16]: %pylab
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib
If you are not using Ipython and the %pylab
magic you will have to use something like:
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 inline from the command line.
I would recommend using Ipython to start with.
This is a link to the Ipython commands quick reference
When I got the same problem I changed figsize() from function call to assignment figsize = (15,5)
And it worked for me.
You might be using an earlier version of pandas. The function figsize()
may have been introduced in a later version.
In version 1.13 I achieved something similar with a statement like df.plot(figsize=(15, 5))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With