Pandas.reset_option() function in Python

28 Jun, 2022
Pandas have an options system that lets us customize some aspects of its behavior, display-related options being those the user is most likely to adjust. Let us see how to reset the value of a specified option back to its default value.
Syntax : pandas.reset_option(pat) 
Parameters : 
pat : Regexp which should match a single option.
Returns : None
Example 1 : We will change the value of an option using pandas.get_option(), we will then reset it back to its default value using pandas.reset_option(). 
Python3
# importing the moduleimport pandas as pd # setting the valuespd.set_option("display.max_rows", 10)pd.set_option("display.min_rows", 2)pd.set_option("display.max_columns", 5)pd.set_option("display.html.border", 3)pd.set_option("io.excel.xlsm.reader", "openpyxl") # displaying the valuesprint("The altered values are : ")print("Value of max_rows : " +      str(pd.get_option("display.max_rows"))) print("Value of min_rows : " +      str(pd.get_option("display.max_columns"))) print("Value of max_columns : " +      str(pd.get_option("display.max_columns"))) print("Value of border : " +      str(pd.get_option("display.html.border"))) print("Value of xlsm reader : " +      str(pd.get_option("io.excel.xlsm.reader"))) # resetting the values to defaultpd.reset_option("display.max_rows")pd.reset_option("display.min_rows")pd.reset_option("display.max_columns")pd.reset_option("display.html.border")pd.reset_option("io.excel.xlsm.reader") # displaying the default valuesprint("\nThe default values are : ") print("Value of max_rows : " +      str(pd.get_option("display.max_rows"))) print("Value of min_rows : " +      str(pd.get_option("display.max_columns"))) print("Value of max_columns : " +      str(pd.get_option("display.max_columns"))) print("Value of border : " +      str(pd.get_option("display.html.border"))) print("Value of xlsm reader : " +      str(pd.get_option("io.excel.xlsm.reader")))
Output :
  
Example 2 : Instead of individually resetting the values of different options, we can reset the values of all the options at once by passing “all” as the parameter in the pandas.reset_option() function. 
Python3
# importing the moduleimport pandas as pd # setting the valuespd.set_option("display.max_rows", 10)pd.set_option("display.min_rows", 2)pd.set_option("display.max_columns", 5)pd.set_option("display.html.border", 3)pd.set_option("io.excel.xlsm.reader", "openpyxl") # displaying the valuesprint("The altered values are : ") print("Value of max_rows : " +      str(pd.get_option("display.max_rows"))) print("Value of min_rows : " +      str(pd.get_option("display.max_columns"))) print("Value of max_columns : " +      str(pd.get_option("display.max_columns"))) print("Value of border : " +      str(pd.get_option("display.html.border"))) print("Value of xlsm reader : " +      str(pd.get_option("io.excel.xlsm.reader"))) # resetting the values to defaultpd.reset_option("all") # displaying the default valuesprint("\nThe default values are : ") print("Value of max_rows : " +      str(pd.get_option("display.max_rows"))) print("Value of min_rows : " +      str(pd.get_option("display.max_columns"))) print("Value of max_columns : " +      str(pd.get_option("display.max_columns"))) print("Value of border : " +      str(pd.get_option("display.html.border"))) print("Value of xlsm reader : " +      str(pd.get_option("io.excel.xlsm.reader")))
Output :
 
surinderdawra388
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.