Skip to content

Commit cd4bc8a

Browse files
committed
API: Remove kwargs from GroupBy
1 parent 18efcb2 commit cd4bc8a

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

pandas/core/generic.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -7829,7 +7829,7 @@ def groupby(
78297829
group_keys=True,
78307830
squeeze=False,
78317831
observed=False,
7832-
**kwargs
7832+
mutated=False,
78337833
):
78347834
"""
78357835
Group DataFrame or Series using a mapper or by a Series of columns.
@@ -7874,10 +7874,8 @@ def groupby(
78747874
If False: show all values for categorical groupers.
78757875
78767876
.. versionadded:: 0.23.0
7877-
7878-
**kwargs
7879-
Optional, only accepts keyword argument 'mutated' and is passed
7880-
to groupby.
7877+
mutated : bool, False
7878+
`mutated`is passed to groupby.
78817879
78827880
Returns
78837881
-------
@@ -7955,7 +7953,7 @@ def groupby(
79557953
group_keys=group_keys,
79567954
squeeze=squeeze,
79577955
observed=observed,
7958-
**kwargs
7956+
mutated=mutated,
79597957
)
79607958

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

pandas/core/groupby/groupby.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@ def __init__(
349349
grouper=None,
350350
exclusions=None,
351351
selection=None,
352-
as_index=True,
353-
sort=True,
354-
group_keys=True,
355-
squeeze=False,
356-
observed=False,
357-
**kwargs
352+
as_index: bool = True,
353+
sort: bool = True,
354+
group_keys: bool = True,
355+
squeeze: bool = False,
356+
observed: bool = False,
357+
mutated: bool = False,
358358
):
359359

360360
self._selection = selection
@@ -376,7 +376,7 @@ def __init__(
376376
self.group_keys = group_keys
377377
self.squeeze = squeeze
378378
self.observed = observed
379-
self.mutated = kwargs.pop("mutated", False)
379+
self.mutated = mutated
380380

381381
if grouper is None:
382382
from pandas.core.groupby.grouper import get_grouper
@@ -396,9 +396,6 @@ def __init__(
396396
self.grouper = grouper
397397
self.exclusions = set(exclusions) if exclusions else set()
398398

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

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)