pandas中set_option的常用設定:顯示所有行、顯示所有列、控制浮點型精度、每個資料元素的顯示字符數、對齊形式等
#pandas中set_option的常用設定
詳細參考pandas API
pandas.set_option — pandas 1.3.5 documentation
pd.set_option("引數",值):設定pandas的默認引數,在實際應用中會常常遇到,所以本人好好學習了一下API參考文獻,結合實際案例進行闡釋,
#顯示所有列
pd.set_option('display.max_columns', None)
#顯示所有行
pd.set_option('display.max_rows', None)
#設定value的顯示長度為100,默認為50
pd.set_option('max_colwidth',100)
# 最大行數
pd.set_option('display.max_rows',xxx)
# 最小顯示行數
pd.set_option('display.min_rows',xxx)
# 最大顯示列數
pd.set_option('display.max_columns',xxx)
#最大列字符數
pd.set_option ('display.max_colwidth',xxx)
# 浮點型精度
pd.set_option( 'display.precision',2)
#逗號分隔數字
pd.set_option('display.float_format','{:,}'.format)
#設定浮點精度
pd.set_option('display.float_format', '{:,.2f}'.format)
#百分號格式化
pd.set_option('display.float_format', '{:.2f}%'.format)
# 更改后端繪圖方式
pd.set_option('plotting.backend', 'altair')
# info輸出最大列數
pd.set_option('display.max_info_columns', 200)
# info計數null時的閾值
pd.set_option('display.max_info_rows', 5)
#展示所有設定和描述
pd.describe_option()
#設定列名對齊
pd.set_option('display.unicode.ambiguous_as_wide', True)
#設定列名對齊
pd.set_option('display.unicode.east_asian_width', True)
#顯示所有行
pd.set_option('display.max_rows',None)
#顯示所有列
pd.set_option('display.max_columns',None)
#設定不換行
pd.set_option('expand_frame_repr', False)
#顯示小數點后的位數
pd.set_option('precision',1)
#最多顯示的行數
pd.set_option('display.max_rows',3)
#最多顯示的列數
pd.set_option('display.max_columns',3)
#設定列長度
pd.set_option('colwidth',1)
#重置所有設定選項
pd.reset_option('all')

Available options:
-
compute.[use_bottleneck, use_numba, 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, writer]
-
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]
-
io.sql.[engine]
-
mode.[chained_assignment, data_manager, sim_interactive, string_storage, use_inf_as_na, use_inf_as_null]
-
plotting.[backend]
-
plotting.matplotlib.[register_converters]
-
styler.render.[max_elements]
-
styler.sparse.[columns, index]
參考:Pandas DataFrame顯示行和列的資料不全
參考:pandas 8 個常用的 set_option 設定方法
參考:pandas.set_option 用法總結
參考:pd.set_option
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/390361.html
標籤:python
上一篇:獲取MC3074XML命名空間“clr-namespace:EndGrain.View”中不存在標記“AssemblyPartControl”
