基于python 2.7.6 pandas 0.23.4测试
一、显示全部列(Column)
print打印时,显示如下:
[3 rows x 12 columns]
day country_code ... up_response_invalid_error_count up_response_invalid_timeout_count
5 20200729 total ... 19820.0 87695.0
9 20200723 SV ... 385.0 291.0
23 20200723 TR ... 10485.0 1201.0
28 20200723 TH ... 187.0 267.0
30 20200723 TN ... 5238.0 2590.0
33 20200724 BF ... 17490.0 37003.0
43 20200724 BH ... 252.0 309.0
加上如下设置显示所有列:
importpandasaspd
pd.set_option('display.max_columns', None)
# 恢复
pd.reset_option('display.max_columns')
二、显示全部行(Row)
加上如下设置显示全部行:
importpandasaspd
pd.set_option('display.max_rows', None)
# 复原
pd.reset_option('display.max_rows')
三、Cell显示不全,超过50了
加上如下设置value的显示长度为100,默认为50:
importpandasaspd
pd.set_option('max_colwidth',100)
# 复原
pd.reset_option('max_colwidth')
根据自己的需要更改相应的设置即可。set_option()的所有属性:
Available options:
- display.[chop_threshold, colheader_justify, column_space, date_dayfirst,
date_yearfirst, encoding, expand_frame_repr, float_format, height, large_repr]
- display.latex.[escape, longtable, repr]
- display.[line_width, max_categories, max_columns, max_colwidth,
max_info_columns, max_info_rows, max_rows, max_seq_items, memory_usage,
mpl_style, multi_sparse, notebook_repr_html, pprint_nest_depth, precision,
show_dimensions]
- display.unicode.[ambiguous_as_wide, east_asian_width]
- display.[width]
- io.excel.xls.[writer]
- io.excel.xlsm.[writer]
- io.excel.xlsx.[writer]
- io.hdf.[default_format, dropna_table]
- mode.[chained_assignment, sim_interactive, use_inf_as_null]
Parameters
----------
pat : str
Regexp which should match a single option.
Note: partial matches are supported for convenience, but unless you use the
full option name (e.g. x.y.z.option_name), your code may break in future
versions if new options with similar names are introduced.
value :
new value of option.
Returns
-------
None
Raises
------
OptionError if no such option exists
Notes