get_option() | Get the value of the input option. |
set_option() | Set the value for the input option |
import pandas as pd
print(pd.get_option("display.max_rows")) # 60
Using set_option() we will change this value to 6.pd.set_option("display.max_rows",6)
print(pd.get_option("display.max_rows")) # 6
Let us read our student excel file ( you can download and use ) having 35 rows of data and display the rows after using set_option()
import pandas as pd
my_data = pd.read_excel('D:\student.xlsx',index_col='id')
pd.set_option("display.max_rows",6)
print(pd.get_option("display.max_rows")) # 6
print(my_data)
Output
6
name class1 mark sex
id
1 John Deo Four 75 female
2 Max Ruin Three 85 male
3 Arnold Three 55 male
.. ... ... ... ...
33 Kenn Rein Six 96 female
34 Gain Toe Seven 69 male
35 Rows Noump Six 88 female
[35 rows x 4 columns]
print(pd.get_option("display.max_columns")) # 20
pd.set_option("display.max_columns",3)
print(my_data)
Output
20
name ... sex
id ...
1 John Deo ... female
2 Max Ruin ... male
3 Arnold ... male
.. ... ... ...
33 Kenn Rein ... female
34 Gain Toe ... male
35 Rows Noump ... female
[35 rows x 4 columns]
Like this there are several options available and we can update the values of these function. A list of such options with detail description is available by using describe_option()
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.