2015-09-14 91 views
2

我是新來的蟒蛇和大熊貓。我們如何在多列上應用groupby和aggregate來忽略空白/無/ NaN值? 基本上,我想聚合日期的列,並採取其餘列忽略None /空白/ NaN值的計數。熊貓羣體聚合忽略空白或無值

例子: 我有這樣的數據:

ID Ra out recommen navi Time 
0 1 7 None None NaN 2013-11-11 
1 2 1 None None 3 2013-11-11 
2 5 5 None None 1 2013-11-12 
3 6 9 None None NaN 2013-11-12 
4 9 2 None None NaN 2013-11-12 
5 10 10 None None NaN 2013-11-12 
6 11 10 None None NaN 2013-11-12 
7 12 10 None None NaN 2013-11-12 
8 13 5 None None NaN 2013-11-12 

我試圖應用GROUPBY和指望這些值作爲agregation功能:日常= df.groupby (「時代」)數( )

這給了我:

ID Ra out recommen navi Time 
2 2 2 2   2  2013-11-11 
7 7 7 7   7  2013-11-12 

教人口會d輸出爲:

ID Ra out recommen navi Time 
2 0 0 0   1  2013-11-11 
7 0 0 0   1  2013-11-12 

Thankyou提前!

回答