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 rows per default in ipython notebook, but I have to slice to view the resulting rows. Even the following option does not change the output:
pd.set_option('display.max_rows', 500)
Does anyone know how to display the whole array?
As in this answer to a similar question, there is no need to hack settings. It is much simpler to write:
It was already pointed in this comment and in this answer, but I'll try to give a more direct answer to the question:
pandas.option_context is available since pandas 0.13.1 (pandas 0.13.1 release notes). According to this,
As @hanleyhansen noted in a comment, as of version 0.18.1, the
display.height
option is deprecated, and says "usedisplay.max_rows
instead". So you just have to configure it like this:See the Release Notes — pandas 0.18.1 documentation:
For version 0.11.0 you need to change both
display.height
anddisplay.max_rows
.See also
pd.describe_option('display')
.Personally, I like setting the options directly with an assignment statement as it is easy to find via tab completion thanks to iPython. I find it hard to remember what the exact option names are, so this method works for me.
For instance, all I have to remember is that it begins with
pd.options
Most of the options are available under
display
From here, I usually output what the current value is like this:
I then set it to what I want it to be:
Also, you should be aware of the context manager for options, which temporarily sets the options inside of a block of code. Pass in the option name as a string followed by the value you want it to be. You may pass in any number of options in the same line:
You can also reset an option back to its default value like this:
And reset all of them back:
It is still perfectly good to set options via
pd.set_option
. I just find using the attributes directly is easier and there is less need forget_option
andset_option
.