3-7显示设置

In [1]:
import pandas as pd
 

此网站可以查找具体的设置属性等:

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.set_option.html#pandas.set_option

 

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]:
 
  0 1 2 3 4 5 6 7 8 9 ... 20 21 22 23 24 25 26 27 28 29

0 rows × 30 columns

 

2-2设置最大列数

In [8]:
pd.set_option('display.max_columns',30)
pd.DataFrame(columns=range(0,30))#此集合只能显示30列
Out[8]:
 
  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 

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

猜你喜欢

转载自www.cnblogs.com/AI-robort/p/11636778.html