2013-11-29 52 views
0

我想將一個填充大量數據的默認字典轉換爲熊貓數據框。當值的字典中的#小(例如10),我得到的是這樣的:熊貓數據框:大量的字典值,打印方式?

 Obama Romney  dates 
    0 47.5 41.5 2/01/2011 
    1 47.5 41.5 2/02/2011 
    2 47.5 41.5 2/03/2011 
    3 47.5 41.5 2/04/2011 
    4 47.5 41.5 2/05/2011 
    5 47.5 41.5 2/06/2011 
    6 46.4 42.0 2/07/2011 
    7 46.4 42.0 2/08/2011 
    8 46.7 42.7 2/09/2011 
    9 46.7 42.7 2/10/2011 
    10 47.3 42.0 2/11/2011 

,當我嘗試打印數據框 - 這就是我想要的。但是,當項目是100以上,我只是得到一個總結:

<class 'pandas.core.frame.DataFrame'> 
    Int64Index: 652 entries, 0 to 651 
    Data columns (total 3 columns): 
    Obama  652 non-null values 
    Romney 652 non-null values 
    dates  652 non-null values 
    dtypes: object(3) 

有沒有什麼方式進行了10項以前做打印的價值?

+0

你不能只通過行循環? – aIKid

回答

3

退房的set_option功能:

import pandas as pd 

pd.set_option('max_rows', 150) 
+0

僅供參考,更改0.13! –

1

你想head,它看起來在第一n行(默認N = 5):

In [11]: df.head() # equivalent to df.head(5) 
Out[11]: 
    Obama Romney  dates 
0 47.5 41.5 2/01/2011 
1 47.5 41.5 2/02/2011 
2 47.5 41.5 2/03/2011 
3 47.5 41.5 2/04/2011 
4 47.5 41.5 2/05/2011 

或它的反面,tail,爲最後n行。

請注意,這是令人困惑的:it's changing in 0.13。下面是當前行爲主的/ dev:

In [21]: pd.concat([df] * 100) # 100 copies of df 
Out[21]: 
    Obama Romney  dates 
0 47.5 41.5 2/01/2011 
1 47.5 41.5 2/02/2011 
2 47.5 41.5 2/03/2011 
# ommiting a load of lines here 
# which make it up to 100 (pd.options.display.max_rows) 
3 47.5 41.5 2/04/2011 
4 47.5 41.5 2/05/2011 
     ...  ...  ... 

[1100 rows x 3 columns]