Pandas: Installation no. maximum rows

I have a problem viewing the following DataFrame :

 n = 100 foo = DataFrame(index=range(n)) foo['floats'] = np.random.randn(n) foo 

The problem is that it does not print all the lines by default in the ipython laptop, but I need to slice to view the resulting lines. Even the following parameter does not change the output:

 pd.set_option('display.max_rows', 500) 

Does anyone know how to display the whole array?

+48
python pandas formatting ipython-notebook
May 7 '13 at 16:52
source share
4 answers

For version 0.11.0 you need to change both display.height and display.max_rows .

 pd.set_option('display.height', 500) pd.set_option('display.max_rows', 500) 

See also pd.describe_option('display') .

+85
May 8 '13 at 6:20
source share

As @hanleyhansen noted in his comment, since version 0.18.1 the display.height parameter is deprecated and says "use display.max_rows instead." Therefore, you just need to configure it as follows:

 pd.set_option('display.max_rows', 500) 

See release notes - pandas 0.18.1 documentation :

The deprecated display.height, display.width now only the formatting option does not control the launch of the summary, similar to <0.11.0.

+4
May 08 '17 at 12:39 a.m.
source share

As in this answer to a similar question , there is no need to hack the settings. It is much easier to write:

 print(foo.to_string()) 
+1
Jan 05 '17 at 2:47 on
source share

Personally, I like to adjust the parameters directly with the assignment operator, since it is easy to find through tab completion thanks to iPython. I find it difficult to remember what exact parameter names are, so this method works for me.

For example, all I have to remember is that it starts with pd.options

 pd.options.<TAB> 

enter image description here

Most options are available in display

 pd.options.display.<TAB> 

enter image description here

From here, I usually infer that the current value is as follows:

 pd.options.display.max_rows 60 

Then I install it the way I want:

 pd.options.display.max_rows = 100 

In addition, you should be aware of the context manager for parameters, which temporarily sets parameters inside a code block. Pass the option name as a string, followed by the value you want. You can pass any number of parameters in one line:

 with pd.option_context('display.max_rows', 100, 'display.max_columns', 10): some pandas stuff 

You can also return reset to a default value similar to this:

 pd.reset_option('display.max_rows') 

And reset all of them:

 pd.reset_option('all') 

It is still fine to set parameters via pd.set_option . I just find that using attributes directly is easier and less get_option and set_option .

0
Nov 04 '17 at 17:46 on
source share



All Articles