zoukankan      html  css  js  c++  java
  • set_option()函数

    这个函数用于设置dataframe的输出显示,

    import pandas as pd
    
    pd.set_option('expand_frame_repr', True)
    # True就是可以换行显示。设置成False的时候不允许换行
    
    pd.set_option('display.max_rows', 10)
    pd.set_option('display.max_rows', None)      # 显示所有行
    pd.set_option('display.max_columns', 10)
    pd.set_option('display.max_columns', None)  # 显示所有列
    # 显示的最大行数和列数,如果超额就显示省略号,这个指的是多少个dataFrame的列。
    # 如果比较多又不允许换行,就会显得很乱。
    
    pd.set_option('precision', 5)
    # 显示小数点后的位数
    
    pd.set_option('display.float_format', lambda x: '%.5f' % x)
    #为了直观的显示数字,不采用科学计数法
    
    pd.set_option('max_colwidth', 5)
    # 用于设置列中单独元素的最大长度,默认为50
    
    pd.set_option('chop_threshold', 0.5)
    # 绝对值小于0.5的显示0.0
    
    pd.set_option('colheader_justify', 'left')
    # 显示居中还是左边,
    
    pd.set_option('display.width', 200)
    # 横向最多显示多少个字符, 一般80不适合横向的屏幕,平时多用200.
    
    pd.set_option('max_colwidth', 10000)
    df = pd.DataFrame({ 'a':[[6]*1000,5,3,5,6,7],
                        'b':[4]*6,
                        'c':[5]*6,
                        'v':[7]*6})
    print(df)
    View Code

    官网:http://pandas-docs.github.io/pandas-docs-travis/reference/api/pandas.set_option.html?highlight=set_option

  • 相关阅读:
    201403-1
    201312-5 I’m stuck!
    201312-4
    201312-3
    201312-2 ISBN号码
    深度学习-李宏毅PPT总结
    梯度下降
    离散时间信号与系统-频域:5
    离散时间信号与系统-时域:4
    离散时间信号与系统-时域:3
  • 原文地址:https://www.cnblogs.com/xxswkl/p/11491350.html
Copyright © 2011-2022 走看看