2014-11-25 20 views
0

当我打印DataFrame时,它会在打印输出的底部显示对象的尺寸(n列,k列)。因此,举例来说:熊猫数据帧显示器无尺寸

import pandas as pd 
df = pd.DataFrame({"A": [10,20,30,40,50], "B": [20, 30, 10, 40, 50], "C": [32, 234, 23, 23, 42523]}) 

print(df) 

显示:

A B  C 
0 10 20  32 
1 20 30 234 
2 30 10  23 
3 40 40  23 
4 50 50 42523 

[5 rows x 3 columns] 

有没有一种方法来关闭这个最后一行[5 rows x 3 columns]的显示?

回答

1

是的!使用pd.options.display.show_dimensions = False

原来这里是再版:

In [118]: df 
Out[118]: 
    A B  C 
0 10 20  32 
1 20 30 234 
2 30 10  23 
3 40 40  23 
4 50 50 42523 

[5 rows x 3 columns] 

设置show_dimensions后=假:

In [119]: pd.options.display.show_dimensions = False 

In [120]: df 
Out[120]: 
    A B  C 
0 10 20  32 
1 20 30 234 
2 30 10  23 
3 40 40  23 
4 50 50 42523 

the pd.get_option docstringprint(pd.get_option.__doc__)更多的所有选项

+0

BTW,与最新的大熊猫,这些小数据帧的尺寸不再显示,仅在数据帧输出被截断时显示(很多行/列)。 – joris 2014-11-25 01:24:25

+0

正确;我通过使用'pd.options.display.show_dimensions = True'来显示维度。 – unutbu 2014-11-25 01:43:03