Pandas 具有一個選項係統,可以讓您自定義其行為的某些方麵,display-related選項是用戶最有可能調整的選項。讓我們看看如何查看指定選項的值。
get_option()
用法:pandas.get_option(pat)
參數:
- pat:正則表達式應與單個選項匹配。
返回值:期權的價值
raise :OptionError如果不存在這樣的選項
範例1:獲取可顯示的最大列數和最小行數的值。
# importing the module
import pandas as pd
# fetching maximum number of
# columns that can be diplayed
print("The value of max_columns:" +
str(pd.get_option("display.max_columns")))
# fetching maximum number of
# rows that can be diplayed
print("The value of max_rows:" +
str(pd.get_option("display.max_rows")))
# fetching minimum number of
# rows that can be diplayed
print("The value of min_rows:" +
str(pd.get_option("display.min_rows")))
輸出:
輸出可能會有所不同。
範例2:提取與Excel文件相關的屬性。
# 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")))
輸出:
相關用法
- Python Wand function()用法及代碼示例
- Python tell()用法及代碼示例
- Python id()用法及代碼示例
- Python map()用法及代碼示例
- Python dir()用法及代碼示例
- Python cmp()用法及代碼示例
- Python int()用法及代碼示例
- Python ord()用法及代碼示例
- Python hex()用法及代碼示例
- Python now()用法及代碼示例
- Python oct()用法及代碼示例
- Python str()用法及代碼示例
- Python sum()用法及代碼示例
- Python seek()用法及代碼示例
- Python reversed()用法及代碼示例
注:本文由純淨天空篩選整理自Yash_R大神的英文原創作品 Pandas.get_option() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。