19  设置

19.1 pandas常见设置及解释

详情:https://pandas.pydata.org/docs/reference/api/pandas.set_option.html#pandas-set-option

  1. pd.set_option('display.max_columns', n):设置在DataFrame中显示的最大列数。将n替换为您希望显示的最大列数。

  2. pd.set_option('display.max_rows', n):设置在DataFrame中显示的最大行数。将n替换为您希望显示的最设置为None时则不限制。大行数。

  3. pd.set_option('display.max_colwidth', n):设置在DataFrame中显示的列宽度的最大字符数。将n替换为您希望的设置为None时则不限制。最大列宽度。

  4. pd.set_option('display.precision', n):设置在DataFrame中显示的数值的小数位数。将n替换为您希望的小数位数。

  5. pd.set_option('display.float_format', lambda x: '{:.2f}'.format(x)):设置在DataFrame中显示浮点数的格式。此示例将浮点数格式化为两位小数。

  6. pd.set_option('display.expand_frame_repr', False):设置当DataFrame显示太宽时,是否允许换行显示。将False替换为True以允许换行。

  7. pd.set_option('display.max_info_columns', n):设置在DataFrame的info()方法中显示的最大列数。将n替换为您希望显示的最大列数。

  8. pd.set_option('display.memory_usage', False):设置是否在DataFrame的info()方法中显示内存使用情况。将False替换为ns')将返回当前设置的最大列数。

19.2 全部可设置选项

import pandas as pd
?pd.set_option