-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Add numeric_only
to function signature of DataFrameGroupBy.cumprod
and `DataFrameGroupBy.cumsum
#53071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
take |
@phofl something like? @final
@Substitution(name="groupby")
@Appender(_common_see_also)
def cumprod(
self, axis: Axis | lib.NoDefault = lib.no_default, numeric_only: bool = False, *args, **kwargs
) -> NDFrameT:
"""
Cumulative product for each group.
Returns
-------
Series or DataFrame
"""
nv.validate_groupby_func("cumprod", args, kwargs, ["skipna"])
if axis is not lib.no_default:
axis = self.obj._get_axis_number(axis)
self._deprecate_axis(axis, "cumprod")
else:
axis = 0
if axis != 0:
f = lambda x: x.cumprod(axis=axis, **kwargs)
return self._python_apply_general(f, self._selected_obj, is_transform=True)
return self._cython_transform("cumprod", numeric_only=numeric_only, **kwargs)
@final
@Substitution(name="groupby")
@Appender(_common_see_also)
def cumsum(
self, axis: Axis | lib.NoDefault = lib.no_default, numeric_only: bool = False, *args, **kwargs
) -> NDFrameT:
"""
Cumulative sum for each group.
Returns
-------
Series or DataFrame
"""
nv.validate_groupby_func("cumsum", args, kwargs, ["skipna"])
if axis is not lib.no_default:
axis = self.obj._get_axis_number(axis)
self._deprecate_axis(axis, "cumsum")
else:
axis = 0
if axis != 0:
f = lambda x: x.cumsum(axis=axis, **kwargs)
return self._python_apply_general(f, self._selected_obj, is_transform=True)
return self._cython_transform("cumsum", numeric_only=numeric_only, **kwargs) |
Yeah, we should probably add skipna as well |
Sure |
I can look into this if it's still open @phofl @mroeschke ? |
@ShashwatAgrawal20 are you working on this or can I take it up? |
Go ahead |
take |
take |
@phofl I think the only way we can avoid making this a potentially breaking change is to use the following signature
This accounts for anyone passing in redundant positional/keyword arguments. The alternative would be to remove args and kwargs altogether. Is that something we'd be happy doing? |
If this issue is still open, I'd like to take it |
Hi @willhsp! Are you still working on this? Would love to contribute to this issue if you are not continuing. Thanks! |
take |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Both methods support numeric only but it goes through args or kwargs, which is annoying signature wise.
Issue Description
Add the keyword with the appropriate default
Expected Behavior
See above
Installed Versions
Replace this line with the output of pd.show_versions()
The text was updated successfully, but these errors were encountered: