Skip to content

Commit 803ed0b

Browse files
committed
API: Remove kwargs from GroupBy
1 parent 07efdd4 commit 803ed0b

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

pandas/core/generic.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -7830,7 +7830,7 @@ def groupby(
78307830
group_keys=True,
78317831
squeeze=False,
78327832
observed=False,
7833-
**kwargs
7833+
mutated=False,
78347834
):
78357835
"""
78367836
Group DataFrame or Series using a mapper or by a Series of columns.
@@ -7875,10 +7875,8 @@ def groupby(
78757875
If False: show all values for categorical groupers.
78767876
78777877
.. versionadded:: 0.23.0
7878-
7879-
**kwargs
7880-
Optional, only accepts keyword argument 'mutated' and is passed
7881-
to groupby.
7878+
mutated : bool, False
7879+
`mutated` is passed to groupby.
78827880
78837881
Returns
78847882
-------
@@ -7956,7 +7954,7 @@ def groupby(
79567954
group_keys=group_keys,
79577955
squeeze=squeeze,
79587956
observed=observed,
7959-
**kwargs
7957+
mutated=mutated,
79607958
)
79617959

79627960
def asfreq(self, freq, method=None, how=None, normalize=False, fill_value=None):

pandas/core/groupby/groupby.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class providing the base-class of operations.
2626
from pandas.compat.numpy import function as nv
2727
from pandas.errors import AbstractMethodError
2828
from pandas.util._decorators import Appender, Substitution, cache_readonly
29-
from pandas.util._validators import validate_kwargs
3029

3130
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
3231
from pandas.core.dtypes.common import (
@@ -349,12 +348,12 @@ def __init__(
349348
grouper=None,
350349
exclusions=None,
351350
selection=None,
352-
as_index=True,
353-
sort=True,
354-
group_keys=True,
355-
squeeze=False,
356-
observed=False,
357-
**kwargs
351+
as_index: bool = True,
352+
sort: bool = True,
353+
group_keys: bool = True,
354+
squeeze: bool = False,
355+
observed: bool = False,
356+
mutated: bool = False,
358357
):
359358

360359
self._selection = selection
@@ -376,7 +375,7 @@ def __init__(
376375
self.group_keys = group_keys
377376
self.squeeze = squeeze
378377
self.observed = observed
379-
self.mutated = kwargs.pop("mutated", False)
378+
self.mutated = mutated
380379

381380
if grouper is None:
382381
from pandas.core.groupby.grouper import get_grouper
@@ -396,9 +395,6 @@ def __init__(
396395
self.grouper = grouper
397396
self.exclusions = set(exclusions) if exclusions else set()
398397

399-
# we accept no other args
400-
validate_kwargs("group", kwargs, {})
401-
402398
def __len__(self):
403399
return len(self.groups)
404400

pandas/tests/window/test_grouper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def setup_method(self, method):
1313

1414
def test_mutated(self):
1515

16-
msg = r"group\(\) got an unexpected keyword argument 'foo'"
16+
msg = r"groupby\(\) got an unexpected keyword argument 'foo'"
1717
with pytest.raises(TypeError, match=msg):
1818
self.frame.groupby("A", foo=1)
1919

0 commit comments

Comments
 (0)