@@ -486,7 +486,7 @@ def __getattr__(self, attr):
486486 (type (self ).__name__ , attr ))
487487
488488 def __getitem__ (self , key ):
489- raise NotImplementedError
489+ raise NotImplementedError ( 'Not implemented: %s' % key )
490490
491491 def _make_wrapper (self , name ):
492492 if name not in self ._apply_whitelist :
@@ -695,12 +695,7 @@ def std(self, ddof=1):
695695 For multiple groupings, the result index will be a MultiIndex
696696 """
697697 # 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 ))
704699
705700 def var (self , ddof = 1 ):
706701 """
@@ -715,6 +710,14 @@ def var(self, ddof=1):
715710 f = lambda x : x .var (ddof = ddof )
716711 return self ._python_agg_general (f )
717712
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+
718721 def size (self ):
719722 """
720723 Compute group sizes
@@ -1332,7 +1335,6 @@ def get_group_levels(self):
13321335 'name' : 'group_median'
13331336 },
13341337 'var' : 'group_var' ,
1335- 'std' : 'group_var' ,
13361338 'first' : {
13371339 'name' : 'group_nth' ,
13381340 'f' : lambda func , a , b , c , d : func (a , b , c , d , 1 )
@@ -1341,10 +1343,6 @@ def get_group_levels(self):
13411343 'count' : 'group_count' ,
13421344 }
13431345
1344- _cython_transforms = {
1345- 'std' : np .sqrt ,
1346- }
1347-
13481346 _cython_arity = {
13491347 'ohlc' : 4 , # OHLC
13501348 }
@@ -1455,7 +1453,6 @@ def aggregate(self, values, how, axis=0):
14551453
14561454 def _aggregate (self , result , counts , values , how , is_numeric ):
14571455 agg_func , dtype = self ._get_aggregate_function (how , values )
1458- trans_func = self ._cython_transforms .get (how , lambda x : x )
14591456
14601457 comp_ids , _ , ngroups = self .group_info
14611458 if values .ndim > 3 :
@@ -1469,7 +1466,7 @@ def _aggregate(self, result, counts, values, how, is_numeric):
14691466 else :
14701467 agg_func (result , counts , values , comp_ids )
14711468
1472- return trans_func ( result )
1469+ return result
14731470
14741471 def agg_series (self , obj , func ):
14751472 try :
@@ -1669,7 +1666,6 @@ def names(self):
16691666 'min' : 'group_min_bin' ,
16701667 'max' : 'group_max_bin' ,
16711668 'var' : 'group_var_bin' ,
1672- 'std' : 'group_var_bin' ,
16731669 'ohlc' : 'group_ohlc' ,
16741670 'first' : {
16751671 'name' : 'group_nth_bin' ,
@@ -1688,7 +1684,6 @@ def names(self):
16881684 def _aggregate (self , result , counts , values , how , is_numeric = True ):
16891685
16901686 agg_func , dtype = self ._get_aggregate_function (how , values )
1691- trans_func = self ._cython_transforms .get (how , lambda x : x )
16921687
16931688 if values .ndim > 3 :
16941689 # punting for now
@@ -1699,7 +1694,7 @@ def _aggregate(self, result, counts, values, how, is_numeric=True):
16991694 else :
17001695 agg_func (result , counts , values , self .bins )
17011696
1702- return trans_func ( result )
1697+ return result
17031698
17041699 def agg_series (self , obj , func ):
17051700 dummy = obj [:0 ]
0 commit comments