diff --git a/doc/source/whatsnew/v0.15.2.txt b/doc/source/whatsnew/v0.15.2.txt index e6843f4a71f72..66b839ed01a29 100644 --- a/doc/source/whatsnew/v0.15.2.txt +++ b/doc/source/whatsnew/v0.15.2.txt @@ -42,3 +42,4 @@ Experimental Bug Fixes ~~~~~~~~~ +- Bug in ``groupby`` signatures that didn't include *args or **kwargs (:issue:`8733`). diff --git a/pandas/tests/test_groupby.py b/pandas/tests/test_groupby.py index b0b521141c92c..ef3fc03fc8d22 100644 --- a/pandas/tests/test_groupby.py +++ b/pandas/tests/test_groupby.py @@ -4415,6 +4415,26 @@ def test_regression_whitelist_methods(self) : expected = getattr(frame,op)(level=level,axis=axis) assert_frame_equal(result, expected) + def test_regression_kwargs_whitelist_methods(self): + # GH8733 + + index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'], + ['one', 'two', 'three']], + labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], + [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]], + names=['first', 'second']) + raw_frame = DataFrame(np.random.randn(10, 3), index=index, + columns=Index(['A', 'B', 'C'], name='exp')) + + grouped = raw_frame.groupby(level=0, axis=1) + grouped.all(test_kwargs='Test kwargs') + grouped.any(test_kwargs='Test kwargs') + grouped.cumcount(test_kwargs='Test kwargs') + grouped.mad(test_kwargs='Test kwargs') + grouped.cummin(test_kwargs='Test kwargs') + grouped.skew(test_kwargs='Test kwargs') + grouped.cumprod(test_kwargs='Test kwargs') + def test_groupby_blacklist(self): from string import ascii_lowercase letters = np.array(list(ascii_lowercase)) @@ -4460,6 +4480,9 @@ def test_series_groupby_plotting_nominally_works(self): tm.close() height.groupby(gender).hist() tm.close() + #Regression test for GH8733 + height.groupby(gender).plot(alpha=0.5) + tm.close() def test_plotting_with_float_index_works(self): _skip_if_mpl_not_installed() diff --git a/pandas/util/decorators.py b/pandas/util/decorators.py index e88bb906dc966..d839437a6fe33 100644 --- a/pandas/util/decorators.py +++ b/pandas/util/decorators.py @@ -282,5 +282,9 @@ def make_signature(func) : args = [] for i, (var, default) in enumerate(zip(spec.args, defaults)) : args.append(var if default=='' else var+'='+repr(default)) + if spec.varargs: + args.append('*' + spec.varargs) + if spec.keywords: + args.append('**' + spec.keywords) return args, spec.args