当
pd.set_option('display.max_columns', None)
设置显示的最大列数,选择
pd.set_option('display.max_colwidth', -1)
设置每个字段的最大宽度。
为了达到我的目的,我编写了一个小的helper函数来完全打印大数据帧,而不影响其余代码,它还重新格式化浮点数并设置虚拟显示宽度。您可以在您的用例中采用它。
def print_full(x):
pd.set_option('display.max_rows', len(x))
pd.set_option('display.max_columns', None)
pd.set_option('display.width', 2000)
pd.set_option('display.float_format', '{:20,.2f}'.format)
pd.set_option('display.max_colwidth', -1)
print(x)
pd.reset_option('display.max_rows')
pd.reset_option('display.max_columns')
pd.reset_option('display.width')
pd.reset_option('display.float_format')
pd.reset_option('display.max_colwidth')