I have a problem viewing the following DataFrame
:
JavaScript
x
5
1
n = 100
2
foo = DataFrame(index=range(n))
3
foo['floats'] = np.random.randn(n)
4
foo
5
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:
JavaScript
1
2
1
pd.set_option('display.max_rows', 500)
2
Does anyone know how to display the whole array?
Advertisement
Answer
Set display.max_rows
:
JavaScript
1
2
1
pd.set_option('display.max_rows', 500)
2
For older versions of pandas (<=0.11.0) you need to change both display.height
and display.max_rows
.
JavaScript
1
3
1
pd.set_option('display.height', 500)
2
pd.set_option('display.max_rows', 500)
3
See also pd.describe_option('display')
.
You can set an option only temporarily for this one time like this:
JavaScript
1
5
1
from IPython.display import display
2
with pd.option_context('display.max_rows', 100, 'display.max_columns', 10):
3
display(df) #need display to show the dataframe when using with in jupyter
4
#some pandas stuff
5
You can also reset an option back to its default value like this:
pd.reset_option('display.max_rows')
And reset all of them back:
pd.reset_option('all')