@@ -41,6 +41,7 @@ class providing the base-class of operations.
4141)
4242from pandas .core .dtypes .missing import isna , notna
4343
44+ from pandas .core import nanops
4445import pandas .core .algorithms as algorithms
4546from pandas .core .arrays import Categorical
4647from pandas .core .base import (
@@ -721,6 +722,10 @@ def f(g):
721722 with np .errstate (all = "ignore" ):
722723 return func (g , * args , ** kwargs )
723724
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+
724729 else :
725730 raise ValueError (
726731 "func must be a callable if args or kwargs are supplied"
@@ -1297,16 +1302,9 @@ def var(self, ddof=1, *args, **kwargs):
12971302 """
12981303 nv .validate_groupby_func ("var" , args , kwargs )
12991304 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+ )
13101308 else :
13111309 f = lambda x : x .var (ddof = ddof , ** kwargs )
13121310 with _group_selection_context (self ):
0 commit comments