2015-05-03 72 views
1

我有一個名爲ratings_by_title,看起來像熊貓的GroupBy數據幀如下:索引熊貓Grouby數據幀給出錯誤

title 
$1,000,000 Duck (1971)    37 
'Night Mother (1986)     70 
'Til There Was You (1997)    52 
'burbs, The (1989)     303 
...And Justice for All (1979)  199 
1-900 (1994)       2 
10 Things I Hate About You (1999) 700 
101 Dalmatians (1961)    565 
101 Dalmatians (1996)    364 
12 Angry Men (1957)     616 

我試圖篩選出具有等級> = 250的標題 所以,

我嘗試以下active_titles = ratings_by_title.index[ratings_by_title >= 250]

但是,這給在IPython中說

錯誤

AttributeError: Cannot access attribute 'index' of 'DataFrameGroupBy' objects, try using the 'apply' method

有人能幫我理解發生了什麼嗎?

回答

5

明白了... 分組通過時,應添加大小方法

如)ratings_by_title = data.groupby( '標題')。大小()

這解決了這個問題!

現在我可以索引等:

active_ratings = ratings_by_title.index [ratings_by_title> = 250]