By default, pandas shows you top and bottom 5 rows of a dataframe in jupyter, given that there are too many rows to display:
>>> df.shape
(100, 4)
col0 | col1 | col2 | col3 | |
---|---|---|---|---|
0 | 7 | 17 | 15 | 2 |
1 | 6 | 5 | 5 | 12 |
2 | 10 | 15 | 5 | 15 |
3 | 6 | 19 | 19 | 14 |
4 | 12 | 7 | 4 | 12 |
... | ... | ... | ... | ... |
95 | 2 | 14 | 8 | 16 |
96 | 8 | 8 | 5 | 16 |
97 | 6 | 8 | 9 | 1 |
98 | 1 | 5 | 10 | 15 |
99 | 15 | 9 | 1 | 18 |
I know that this setting exists:
pd.set_option("display.max_rows", 20)
however, that yields the same result. Using df.head(10)
and df.tail(10)
in to consecutive cells is an option, but less clean. Same goes for concatenation. Is there another pandas setting like display.max_row
for this default view? How can I expand this to let's say the top and bottom 10?
CodePudding user response:
IIUC, use display.min_rows
:
pd.set_option("display.min_rows", 20)
print(df)
# Output:
0 1 2 3
0 18 8 12 2
1 2 13 13 14
2 8 7 9 2
3 17 19 9 3
4 14 18 12 3
5 11 5 9 18
6 4 5 12 3
7 12 8 2 7
8 11 2 14 13
9 6 6 3 6
.. .. .. .. ..
90 8 2 1 9
91 7 19 4 6
92 4 3 17 12
93 19 6 5 18
94 3 5 15 5
95 16 3 13 13
96 11 3 18 8
97 1 9 18 4
98 13 10 18 15
99 16 3 5 9
[100 rows x 4 columns]