Skip to content Skip to sidebar Skip to footer

Change Pandas 0.13.0 "print Dataframe" To Print Dataframe Like In Earlier Versions

In the new version 0.13.0 of pandas, a dataframe df is printed in one long list of numbers using df or print df instead of an overview, like before, which is now only possible us

Solution 1:

Set

pd.options.display.large_repr = 'info'

The default as of v.0.13 is 'truncate'.

In [93]: df = pd.DataFrame(np.arange(4319*2).reshape(4319,2))

In [94]: pd.options.display.large_repr = 'info'

In [95]: df
Out[95]: 
<class 'pandas.core.frame.DataFrame'>
Int64Index: 4319 entries, 0 to 4318
Data columns (total 2 columns):
04319 non-null int32
14319 non-null int32
dtypes: int32(2)

I found this by searching for the string 'info()' in the output of:

In [65]: pd.set_option?

To make this the default behavior for interactive sessions:

If you haven't set it already, define the environment variable PYTHONSTARTUP to something like /home/user/bin/startup.py

Then edit/create /home/user/bin/startup.py to contain something like

import pandas as pd
pd.options.display.large_repr = 'info'

Now, whenever you start an interactive Python session, the startup.py file will be executed, you'll have access to pandas through the pd variable, and large_repr default will be 'info'.

Post a Comment for "Change Pandas 0.13.0 "print Dataframe" To Print Dataframe Like In Earlier Versions"