@@ -142,6 +142,11 @@ def _last(x):
142
142
else :
143
143
return _last (x )
144
144
145
+
146
+ def _count_compat (x , axis = 0 ):
147
+ return x .size
148
+
149
+
145
150
class Grouper (object ):
146
151
"""
147
152
A Grouper allows the user to specify a groupby instruction for a target object
@@ -721,8 +726,7 @@ def size(self):
721
726
numeric_only = False , _convert = True )
722
727
last = _groupby_function ('last' , 'last' , _last_compat , numeric_only = False ,
723
728
_convert = True )
724
-
725
- _count = _groupby_function ('_count' , 'count' , lambda x , axis = 0 : x .size (),
729
+ _count = _groupby_function ('_count' , 'count' , _count_compat ,
726
730
numeric_only = False )
727
731
728
732
def count (self , axis = 0 ):
@@ -1386,17 +1390,19 @@ def aggregate(self, values, how, axis=0):
1386
1390
if is_numeric_dtype (values .dtype ):
1387
1391
values = com .ensure_float (values )
1388
1392
is_numeric = True
1393
+ out_dtype = 'f%d' % values .dtype .itemsize
1389
1394
else :
1390
1395
is_numeric = issubclass (values .dtype .type , (np .datetime64 ,
1391
1396
np .timedelta64 ))
1397
+ out_dtype = 'float64'
1392
1398
if is_numeric :
1393
1399
values = values .view ('int64' )
1394
1400
else :
1395
1401
values = values .astype (object )
1396
1402
1397
1403
# will be filled in Cython function
1398
- result = np .empty (out_shape ,
1399
- dtype = np . dtype ( 'f%d' % values . dtype . itemsize ))
1404
+ result = np .empty (out_shape , dtype = out_dtype )
1405
+
1400
1406
result .fill (np .nan )
1401
1407
counts = np .zeros (self .ngroups , dtype = np .int64 )
1402
1408
@@ -1441,7 +1447,6 @@ def _aggregate(self, result, counts, values, how, is_numeric):
1441
1447
chunk = chunk .squeeze ()
1442
1448
agg_func (result [:, :, i ], counts , chunk , comp_ids )
1443
1449
else :
1444
- #import ipdb; ipdb.set_trace() # XXX BREAKPOINT
1445
1450
agg_func (result , counts , values , comp_ids )
1446
1451
1447
1452
return trans_func (result )
0 commit comments