python pandas.set_option()详解

一、简介

set_option是pandas里的一个函数,用法为pandas.set_option(pat, value),主要作用是设置一些指定参数的值。

供设置的选项如下,后面会逐一进行介绍

  • compute.[use_bottleneck, use_numexpr]
  • display.[chop_threshold, colheader_justify, column_space, date_dayfirst, date_yearfirst, encoding, expand_frame_repr, float_format]
  • display.html.[border, table_schema, use_mathjax]
  • display.[large_repr]
  • display.latex.[escape, longtable, multicolumn, multicolumn_format, multirow, repr]
  • display.[max_categories, max_columns, max_colwidth, max_info_columns, max_info_rows, max_rows, max_seq_items, memory_usage, min_rows, multi_sparse, notebook_repr_html, pprint_nest_depth, precision, show_dimensions]
  • display.unicode.[ambiguous_as_wide, east_asian_width]
  • display.[width]
  • io.excel.ods.[reader]
  • io.excel.xls.[reader, writer]
  • io.excel.xlsb.[reader]
  • io.excel.xlsm.[reader, writer]
  • io.excel.xlsx.[reader, writer]
  • io.hdf.[default_format, dropna_table]
  • io.parquet.[engine]
  • mode.[chained_assignment, sim_interactive, use_inf_as_na, use_inf_as_null]
  • plotting.[backend]
  • plotting.matplotlib.[register_converters]

二、参数解释:

pat:字符。可以匹配一个特定选项的正则表达式。
需要注意的是,为了方便起见,目前支持局部的简写来进行匹配,但是为了严谨,最好将该特定选项的名称写完整(如:x.y.z.option_name),要不然以后在其他版本上,局部的简写可能因被系统引用而导致代码运行中断。如果没有匹配到,报错内容为:OptionError: no such option exists

value:对象,可能为数值,或者字符。

三、详解

compute.use_bottleneck:bool
如果安装了bottleneck包的话,会用bottleneck包进行加速计算。默认值为True,有效的value为: False,True [default: True] [currently: True]。bottleneck为C语言编写的快速计算numpy array的包,本文暂不表。

compute.use_numexpr:bool
如果安装了numexpr 包的话,会用numexpr 进行加速计算。默认值为True,有效的value为: False,True [default: True] [currently: True]。

display.chop_threshold:float or None
如果设置了一个浮点型的数值阈值,DataFrame中所有绝对值小于该阈值的数值,都会以0展示。[default: None] [currently: None]
在这里插入图片描述
display.colheader_justify:‘left’/’right’
控制调整列名,调整展示的列名靠左对齐或者右对齐,用DataFrameFormatter来做的。[default: right] [currently: right]
在这里插入图片描述
display.column_space:[default: 12] [currently: 12]
这个官方没有给出说明书,看语义应该是设置列名所占空间的,本人测了几次也没效果,没弄明白具体的作用。

display.date_dayfirst:boolean
当value设置为True,print出来时,会将日期放在最前面。(如:20/01/2005)[default: False] [currently: False]

display.date_yearfirst:boolean
当value设置为True时,print出来时,会将年份放在最前面。(如:2005/01/20)[default: False] [currently: False]

  • 6
    点赞
  • 49
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值