Sunday, November 17, 2024
Google search engine
HomeLanguagesPandas.get_option() function in Python

Pandas.get_option() function in Python

Pandas have an options system that lets you customize some aspects of its behavior, display-related options being those the user is most likely to adjust. Let us see how to see the value of a specified option.

get_option()

Syntax : pandas.get_option(pat)
Parameters : 

  • pat : Regexp which should match a single option.

Returns : Value of the option 
Raises : OptionError if no such option exists 
 

Example 1 : Fetching the value of maximum and minimum number of columns and rows that can be displayed.  

Python3




# importing the module
import pandas as pd
 
# fetching maximum number of
# columns that can be displayed
print("The value of max_columns : " +
      str(pd.get_option("display.max_columns")))
 
# fetching maximum number of
# rows that can be displayed
print("The value of max_rows : " +
      str(pd.get_option("display.max_rows")))
 
# fetching minimum number of
# rows that can be displayed
print("The value of min_rows : " +
      str(pd.get_option("display.min_rows")))


Output : 
 

Output may vary.

Example 2 : Fetching the attributes related to Excel files. 

Python3




# importing the module
import pandas as pd
 
# default Excel reader engine for ‘ods’ files
print("The default Excel reader engine for ‘ods’ files : " +
      str(pd.get_option("io.excel.ods.reader")))
 
# default Excel reader engine for ‘xls’ files
print("The default Excel reader engine for ‘xls’ files : " +
      str(pd.get_option("io.excel.xls.reader")))
 
# default Excel writer engine for ‘xls’ files
print("The default Excel writer engine for ‘xls’ files : " +
      str(pd.get_option("io.excel.xls.writer")))
 
# default Excel reader engine for ‘xlsb’ files
print("The default Excel reader engine for ‘xlsb’ files : " +
      str(pd.get_option("io.excel.xlsb.reader")))
 
# default Excel reader engine for ‘xlsm’ files
print("The default Excel reader engine for ‘xlsm’ files : " +
      str(pd.get_option("io.excel.xlsm.reader")))
 
# default Excel writer engine for ‘xlsm’ files
print("The default Excel writer engine for ‘xlsm’ files : " +
      str(pd.get_option("io.excel.xlsm.writer")))
 
# default Excel reader engine for ‘xlsm’ files
print("The default Excel reader engine for ‘xlsx’ files : " +
      str(pd.get_option("io.excel.xlsx.reader")))
 
# default Excel writer engine for ‘xlsx’ files
print("The default Excel writer engine for ‘xlsx’ files : " +
      str(pd.get_option("io.excel.xlsx.writer")))


Output : 
 

 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments