Функция Pandas.get_option () в Python
У Pandas есть система опций, которая позволяет вам настраивать некоторые аспекты его поведения, причем параметры, связанные с отображением, - это те, которые пользователь, скорее всего, настроит. Давайте посмотрим, как увидеть значение указанной опции.
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
Пример 1: Получение значения максимального и минимального количества столбцов и строк, которые могут отображаться.
# importing the moduleimport pandas as pd # fetching maximum number of # columns that can be diplayedprint("The value of max_columns : " + str(pd.get_option("display.max_columns"))) # fetching maximum number of # rows that can be diplayedprint("The value of max_rows : " + str(pd.get_option("display.max_rows"))) # fetching minimum number of # rows that can be diplayedprint("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.
# importing the moduleimport pandas as pd # default Excel reader engine for ‘ods’ filesprint("The default Excel reader engine for ‘ods’ files : " + str(pd.get_option("io.excel.ods.reader"))) # default Excel reader engine for ‘xls’ filesprint("The default Excel reader engine for ‘xls’ files : " + str(pd.get_option("io.excel.xls.reader"))) # default Excel writer engine for ‘xls’ filesprint("The default Excel writer engine for ‘xls’ files : " + str(pd.get_option("io.excel.xls.writer"))) # default Excel reader engine for ‘xlsb’ filesprint("The default Excel reader engine for ‘xlsb’ files : " + str(pd.get_option("io.excel.xlsb.reader"))) # default Excel reader engine for ‘xlsm’ filesprint("The default Excel reader engine for ‘xlsm’ files : " + str(pd.get_option("io.excel.xlsm.reader"))) # default Excel writer engine for ‘xlsm’ filesprint("The default Excel writer engine for ‘xlsm’ files : " + str(pd.get_option("io.excel.xlsm.writer"))) # default Excel reader engine for ‘xlsm’ filesprint("The default Excel reader engine for ‘xlsx’ files : " + str(pd.get_option("io.excel.xlsx.reader"))) # default Excel writer engine for ‘xlsx’ filesprint("The default Excel writer engine for ‘xlsx’ files : " + str(pd.get_option("io.excel.xlsx.writer"))) |
Output :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course