@@ -681,11 +681,14 @@ def _check_results(grouped):
681
681
assert_frame_equal (result , expected )
682
682
683
683
# group frame by function dict
684
- result = grouped .agg (
685
- OrderedDict ([['A' , 'var' ], ['B' , 'std' ], ['C' , 'mean' ]]))
684
+ result = grouped .agg (OrderedDict ([['A' , 'var' ],
685
+ ['B' , 'std' ],
686
+ ['C' , 'mean' ],
687
+ ['D' , 'sem' ]]))
686
688
expected = DataFrame (OrderedDict ([['A' , grouped ['A' ].var ()],
687
689
['B' , grouped ['B' ].std ()],
688
- ['C' , grouped ['C' ].mean ()]]))
690
+ ['C' , grouped ['C' ].mean ()],
691
+ ['D' , grouped ['D' ].sem ()]]))
689
692
assert_frame_equal (result , expected )
690
693
691
694
by_weekday = self .tsframe .groupby (lambda x : x .weekday ())
@@ -1637,6 +1640,7 @@ def _testit(op):
1637
1640
_testit (lambda x : x .sum ())
1638
1641
_testit (lambda x : x .std ())
1639
1642
_testit (lambda x : x .var ())
1643
+ _testit (lambda x : x .sem ())
1640
1644
_testit (lambda x : x .mean ())
1641
1645
_testit (lambda x : x .median ())
1642
1646
_testit (lambda x : x .prod ())
@@ -4170,8 +4174,8 @@ def test_tab_completion(self):
4170
4174
'agg' ,'aggregate' ,'apply' ,'boxplot' ,'filter' ,'first' ,'get_group' ,
4171
4175
'groups' ,'hist' ,'indices' ,'last' ,'max' ,'mean' ,'median' ,
4172
4176
'min' ,'name' ,'ngroups' ,'nth' ,'ohlc' ,'plot' , 'prod' ,
4173
- 'size' , 'std' , 'sum' , 'transform' , 'var' , 'count ' , 'head ' , 'describe ' ,
4174
- 'cummax' , 'quantile' , 'rank' , 'cumprod' , 'tail' ,
4177
+ 'size' , 'std' , 'sum' , 'transform' , 'var' , 'sem ' , 'count ' , 'head ' ,
4178
+ 'describe' , ' cummax' , 'quantile' , 'rank' , 'cumprod' , 'tail' ,
4175
4179
'resample' , 'cummin' , 'fillna' , 'cumsum' , 'cumcount' ,
4176
4180
'all' , 'shift' , 'skew' , 'bfill' , 'irow' , 'ffill' ,
4177
4181
'take' , 'tshift' , 'pct_change' , 'any' , 'mad' , 'corr' , 'corrwith' ,
@@ -4347,6 +4351,12 @@ def test_ops_general(self):
4347
4351
('last' , lambda x : x .iloc [- 1 ]),
4348
4352
('count' , np .size ),
4349
4353
]
4354
+ try :
4355
+ from scipy .stats import sem
4356
+ except ImportError :
4357
+ pass
4358
+ else :
4359
+ ops .append (('sem' , sem ))
4350
4360
df = DataFrame (np .random .randn (1000 ))
4351
4361
labels = np .random .randint (0 , 50 , size = 1000 ).astype (float )
4352
4362
0 commit comments