@@ -486,7 +486,7 @@ def __getattr__(self, attr):
486
486
(type (self ).__name__ , attr ))
487
487
488
488
def __getitem__ (self , key ):
489
- raise NotImplementedError
489
+ raise NotImplementedError ( 'Not implemented: %s' % key )
490
490
491
491
def _make_wrapper (self , name ):
492
492
if name not in self ._apply_whitelist :
@@ -695,12 +695,7 @@ def std(self, ddof=1):
695
695
For multiple groupings, the result index will be a MultiIndex
696
696
"""
697
697
# todo, implement at cython level?
698
- if ddof == 1 :
699
- return self ._cython_agg_general ('std' )
700
- else :
701
- self ._set_selection_from_grouper ()
702
- f = lambda x : x .std (ddof = ddof )
703
- return self ._python_agg_general (f )
698
+ return np .sqrt (self .var (ddof = ddof ))
704
699
705
700
def var (self , ddof = 1 ):
706
701
"""
@@ -715,6 +710,14 @@ def var(self, ddof=1):
715
710
f = lambda x : x .var (ddof = ddof )
716
711
return self ._python_agg_general (f )
717
712
713
+ def sem (self , ddof = 1 ):
714
+ """
715
+ Compute standard error of the mean of groups, excluding missing values
716
+
717
+ For multiple groupings, the result index will be a MultiIndex
718
+ """
719
+ return self .std (ddof = ddof )/ np .sqrt (self .count ())
720
+
718
721
def size (self ):
719
722
"""
720
723
Compute group sizes
@@ -1332,7 +1335,6 @@ def get_group_levels(self):
1332
1335
'name' : 'group_median'
1333
1336
},
1334
1337
'var' : 'group_var' ,
1335
- 'std' : 'group_var' ,
1336
1338
'first' : {
1337
1339
'name' : 'group_nth' ,
1338
1340
'f' : lambda func , a , b , c , d : func (a , b , c , d , 1 )
@@ -1341,10 +1343,6 @@ def get_group_levels(self):
1341
1343
'count' : 'group_count' ,
1342
1344
}
1343
1345
1344
- _cython_transforms = {
1345
- 'std' : np .sqrt ,
1346
- }
1347
-
1348
1346
_cython_arity = {
1349
1347
'ohlc' : 4 , # OHLC
1350
1348
}
@@ -1455,7 +1453,6 @@ def aggregate(self, values, how, axis=0):
1455
1453
1456
1454
def _aggregate (self , result , counts , values , how , is_numeric ):
1457
1455
agg_func , dtype = self ._get_aggregate_function (how , values )
1458
- trans_func = self ._cython_transforms .get (how , lambda x : x )
1459
1456
1460
1457
comp_ids , _ , ngroups = self .group_info
1461
1458
if values .ndim > 3 :
@@ -1469,7 +1466,7 @@ def _aggregate(self, result, counts, values, how, is_numeric):
1469
1466
else :
1470
1467
agg_func (result , counts , values , comp_ids )
1471
1468
1472
- return trans_func ( result )
1469
+ return result
1473
1470
1474
1471
def agg_series (self , obj , func ):
1475
1472
try :
@@ -1669,7 +1666,6 @@ def names(self):
1669
1666
'min' : 'group_min_bin' ,
1670
1667
'max' : 'group_max_bin' ,
1671
1668
'var' : 'group_var_bin' ,
1672
- 'std' : 'group_var_bin' ,
1673
1669
'ohlc' : 'group_ohlc' ,
1674
1670
'first' : {
1675
1671
'name' : 'group_nth_bin' ,
@@ -1688,7 +1684,6 @@ def names(self):
1688
1684
def _aggregate (self , result , counts , values , how , is_numeric = True ):
1689
1685
1690
1686
agg_func , dtype = self ._get_aggregate_function (how , values )
1691
- trans_func = self ._cython_transforms .get (how , lambda x : x )
1692
1687
1693
1688
if values .ndim > 3 :
1694
1689
# punting for now
@@ -1699,7 +1694,7 @@ def _aggregate(self, result, counts, values, how, is_numeric=True):
1699
1694
else :
1700
1695
agg_func (result , counts , values , self .bins )
1701
1696
1702
- return trans_func ( result )
1697
+ return result
1703
1698
1704
1699
def agg_series (self , obj , func ):
1705
1700
dummy = obj [:0 ]
0 commit comments