Display options#
Here is discussed options to set up pandas displayment in jupyter notebooks.
import numpy as np
import pandas as pd
from IPython.display import HTML
My seetings#
Now I’m using the following settings to set up the display of pandas. So you can just copy/paste it.
pd.set_option("display.max_rows", 1000)
pd.set_option("display.max_columns", 1000)
pd.set_option("display.float_format", "{:.3f}".format)
Interfaces#
You can access the pandas
display options via the pandas.options.display
path. So in the following cell are displayed default falue for some ojects.
print("float_format", pd.options.display.float_format)
print("max_columns", pd.options.display.max_columns)
print("max_rows", pd.options.display.max_rows)
float_format None
max_columns 20
max_rows 60
Through pandas.set_option("display.<property>", <value>)
you can setup values for options. The following example shows how rax_rows
can be setted up with this expression.
pd.set_option("display.max_rows", 10)
print("max_rows", pd.options.display.max_rows)
pd.options.display.max_rows = 60
max_rows 10
float_format
#
Allows to set up the format of the float outputs.
The following example illustrates how a single value, with an extremely small number, can convert all columns into scientific notation. However, by using the pd.set_option('display.float_format', "{:.3f}".format)
function, it will display all numbers in standard notation with only three digits after the decimal point.
np.random.seed(10)
show_frame = pd.DataFrame(
np.random.rand(10, 2)
)
show_frame.iloc[0,0] = 10**(-10)
display(HTML("<p style='font-size:17px'>Default</p>"))
display(show_frame)
display(HTML("<p style='font-size:17px'>Format</p>"))
pd.set_option('display.float_format', "{:.3f}".format)
display(show_frame)
# returning default value
pd.set_option('display.float_format', None)
Default
0 | 1 | |
---|---|---|
0 | 1.000000e-10 | 0.020752 |
1 | 6.336482e-01 | 0.748804 |
2 | 4.985070e-01 | 0.224797 |
3 | 1.980629e-01 | 0.760531 |
4 | 1.691108e-01 | 0.088340 |
5 | 6.853598e-01 | 0.953393 |
6 | 3.948266e-03 | 0.512192 |
7 | 8.126210e-01 | 0.612526 |
8 | 7.217553e-01 | 0.291876 |
9 | 9.177741e-01 | 0.714576 |
Format
0 | 1 | |
---|---|---|
0 | 0.000 | 0.021 |
1 | 0.634 | 0.749 |
2 | 0.499 | 0.225 |
3 | 0.198 | 0.761 |
4 | 0.169 | 0.088 |
5 | 0.685 | 0.953 |
6 | 0.004 | 0.512 |
7 | 0.813 | 0.613 |
8 | 0.722 | 0.292 |
9 | 0.918 | 0.715 |