@@ -41,6 +41,7 @@ class providing the base-class of operations.
41
41
)
42
42
from pandas .core .dtypes .missing import isna , notna
43
43
44
+ from pandas .core import nanops
44
45
import pandas .core .algorithms as algorithms
45
46
from pandas .core .arrays import Categorical
46
47
from pandas .core .base import (
@@ -721,6 +722,10 @@ def f(g):
721
722
with np .errstate (all = "ignore" ):
722
723
return func (g , * args , ** kwargs )
723
724
725
+ elif hasattr (nanops , "nan" + func ):
726
+ # TODO: should we wrap this in to e.g. _is_builtin_func?
727
+ f = getattr (nanops , "nan" + func )
728
+
724
729
else :
725
730
raise ValueError (
726
731
"func must be a callable if args or kwargs are supplied"
@@ -1297,16 +1302,9 @@ def var(self, ddof=1, *args, **kwargs):
1297
1302
"""
1298
1303
nv .validate_groupby_func ("var" , args , kwargs )
1299
1304
if ddof == 1 :
1300
- try :
1301
- return self ._cython_agg_general (
1302
- "var" ,
1303
- alt = lambda x , axis : Series (x ).var (ddof = ddof , ** kwargs ),
1304
- ** kwargs
1305
- )
1306
- except Exception :
1307
- f = lambda x : x .var (ddof = ddof , ** kwargs )
1308
- with _group_selection_context (self ):
1309
- return self ._python_agg_general (f )
1305
+ return self ._cython_agg_general (
1306
+ "var" , alt = lambda x , axis : Series (x ).var (ddof = ddof , ** kwargs ), ** kwargs
1307
+ )
1310
1308
else :
1311
1309
f = lambda x : x .var (ddof = ddof , ** kwargs )
1312
1310
with _group_selection_context (self ):
0 commit comments