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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。