• 3-7显示设置


    In [1]:
    import pandas as pd
    
     

    1-1显示最大的行数

    In [2]:
    pd.get_option('display.max_rows')
    
    Out[2]:
    60
    In [3]:
    pd.Series(index=range(0,100))#此集合只能显示60行
    
    Out[3]:
    0    NaN
    1    NaN
    2    NaN
    3    NaN
    4    NaN
    5    NaN
    6    NaN
    7    NaN
    8    NaN
    9    NaN
    10   NaN
    11   NaN
    12   NaN
    13   NaN
    14   NaN
    15   NaN
    16   NaN
    17   NaN
    18   NaN
    19   NaN
    20   NaN
    21   NaN
    22   NaN
    23   NaN
    24   NaN
    25   NaN
    26   NaN
    27   NaN
    28   NaN
    29   NaN
          ..
    70   NaN
    71   NaN
    72   NaN
    73   NaN
    74   NaN
    75   NaN
    76   NaN
    77   NaN
    78   NaN
    79   NaN
    80   NaN
    81   NaN
    82   NaN
    83   NaN
    84   NaN
    85   NaN
    86   NaN
    87   NaN
    88   NaN
    89   NaN
    90   NaN
    91   NaN
    92   NaN
    93   NaN
    94   NaN
    95   NaN
    96   NaN
    97   NaN
    98   NaN
    99   NaN
    Length: 100, dtype: float64
     

    1-2设置显示最大的行数

    In [4]:
    pd.set_option('display.max_rows',8)
    
    In [5]:
    pd.Series(index=range(0,100))#此集合只能显示8行
    
    Out[5]:
    0    NaN
    1    NaN
    2    NaN
    3    NaN
          ..
    96   NaN
    97   NaN
    98   NaN
    99   NaN
    Length: 100, dtype: float64
     

    2-1显示最大列数

    In [6]:
    pd.get_option('display.max_columns')
    
    Out[6]:
    20
    In [7]:
    pd.DataFrame(columns=range(0,30))#此集合只能显示20列
    
    Out[7]:
     
     0123456789...20212223242526272829

    0 rows × 30 columns

     

    2-2设置最大列数

    In [8]:
    pd.set_option('display.max_columns',30)
    pd.DataFrame(columns=range(0,30))#此集合只能显示30列
    
    Out[8]:
     
     01234567891011121314151617181920212223242526272829
     

    3-1字符串显示最大的宽度

    In [9]:
    pd.get_option('display.max_colwidth')#此字符串只能显示50宽度
    
    Out[9]:
    50
    In [10]:
    pd.Series(index=['a'],data=['t'*70])
    
    Out[10]:
    a    tttttttttttttttttttttttttttttttttttttttttttttt...
    dtype: object
     

    3-2设置字符串显示最大的宽度

    In [11]:
    pd.set_option('display.max_colwidth',10)#此字符串只能显示10宽度
    pd.Series(index=['a'],data=['t'*70])
    
    Out[11]:
    a    tttttt...
    dtype: object
     

    4-1数值的精度显示

    In [13]:
    pd.get_option('display.precision')#此字符串只能显示6宽度
    
    Out[13]:
    6
    In [14]:
    A=pd.Series(data=[1.22153415861441446])
    
     

    4-2设置数值的精度显示

    In [15]:
    pd.set_option('display.precision',5)
    A
    
    Out[15]:
    0    1.22153
    dtype: float64
  • 相关阅读:
    目前加尼福尼亚自动驾驶公司测试公司————20150529
    DDR3
    Linux mysql 5.7: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    macOS 10.12,解决如何打开隐私中的任何来源方法
    git查看某个文件的提交历史
    ios-deploy命令
    sed简用
    啊,栈溢出了
    二叉树题目总结(一)
    线段树(二)
  • 原文地址:https://www.cnblogs.com/AI-robort/p/11636778.html
Copyright © 2020-2023  润新知