You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We pass positional *args through to the aggfunc for a single grouper.
In [1]: importpandasaspdIn [2]: df=pd.DataFrame({"A": [1, 2]})
In [3]: deff(x, y):
...: returnx.sum() +y
...:
In [4]: df.groupby([0, 0]).agg(f, 10)
Out[4]:
A013
But not for multiple.
In [5]: df.groupby([0, 0]).agg([f], 10)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-c8273728b28e> in <module>
----> 1 df.groupby([0, 0]).agg([f], 10)
~/sandbox/pandas/pandas/core/groupby/generic.py in aggregate(self, arg, *args, **kwargs)
1354 @Appender(_shared_docs['aggregate'])
1355 def aggregate(self, arg=None, *args, **kwargs):
-> 1356 return super().aggregate(arg, *args, **kwargs)
1357
1358 agg = aggregate
~/sandbox/pandas/pandas/core/groupby/generic.py in aggregate(self, func, *args, **kwargs)
167 func = func2
168
--> 169 result, how = self._aggregate(func, _level=_level, *args, **kwargs)
170if how isNone:
171return result
~/sandbox/pandas/pandas/core/base.py in _aggregate(self, arg, *args, **kwargs)
534returnself._aggregate_multiple_funcs(arg,
535 _level=_level,
--> 536 _axis=_axis), None
537else:
538 result =None
~/sandbox/pandas/pandas/core/base.py in _aggregate_multiple_funcs(self, arg, _level, _axis)
592# if we are empty593ifnotlen(results):
--> 594 raise ValueError("no results")
595596try:
ValueError: no results
Same for keyword arguments.
Is that intentional? It's a bit strange, since all your aggfuncs would need to be expecting the same positional and keyword arguments. I think we should recommend using something like functools.partial to get a unary function, and documents that args and kwargs aren't passed through for multi-agg.
The text was updated successfully, but these errors were encountered:
I don't see this as being intentional or useful so for sure would be on board with any clean up here and pushing the partial approach if there is a need here
We pass positional
*args
through to the aggfunc for a single grouper.But not for multiple.
Same for keyword arguments.
Is that intentional? It's a bit strange, since all your aggfuncs would need to be expecting the same positional and keyword arguments. I think we should recommend using something like functools.partial to get a unary function, and documents that args and kwargs aren't passed through for multi-agg.
The text was updated successfully, but these errors were encountered: