From 8c64854b68e0810d94f936c39cc7e652609ba877 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 27 Nov 2018 08:39:22 -0500 Subject: [PATCH 1/4] Removed unneeded whitelist entries --- pandas/core/groupby/base.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/pandas/core/groupby/base.py b/pandas/core/groupby/base.py index 1bf97690a84ed..9676beb75f403 100644 --- a/pandas/core/groupby/base.py +++ b/pandas/core/groupby/base.py @@ -66,35 +66,22 @@ def _gotitem(self, key, ndim, subset=None): # special case to prevent duplicate plots when catching exceptions when # forwarding methods from NDFrames -plotting_methods = frozenset(['plot', 'boxplot', 'hist']) +plotting_methods = frozenset(['hist']) common_apply_whitelist = frozenset([ - 'last', 'first', - 'head', 'tail', 'median', - 'mean', 'sum', 'min', 'max', - 'cumcount', 'ngroup', - 'resample', - 'rank', 'quantile', - 'fillna', - 'mad', - 'any', 'all', - 'take', - 'idxmax', 'idxmin', - 'shift', 'tshift', - 'ffill', 'bfill', - 'pct_change', 'skew', - 'corr', 'cov', 'diff', + 'quantile', 'fillna', 'mad', 'take', + 'idxmax', 'idxmin', 'tshift', + 'skew', 'corr', 'cov', 'diff' ]) | plotting_methods series_apply_whitelist = ((common_apply_whitelist | {'nlargest', 'nsmallest', 'is_monotonic_increasing', - 'is_monotonic_decreasing'}) - - {'boxplot'}) | frozenset(['dtype', 'unique']) + 'is_monotonic_decreasing'}) + ) | frozenset(['dtype', 'unique']) dataframe_apply_whitelist = ((common_apply_whitelist | - frozenset(['dtypes', 'corrwith'])) - - {'boxplot'}) + frozenset(['dtypes', 'corrwith']))) cython_transforms = frozenset(['cumprod', 'cumsum', 'shift', 'cummin', 'cummax']) From faa9fd773c5b01e6e246b043a50f3fe5cc7153de Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 27 Nov 2018 08:48:06 -0500 Subject: [PATCH 2/4] Cleaned up whitelist tests --- pandas/tests/groupby/test_whitelist.py | 49 -------------------------- 1 file changed, 49 deletions(-) diff --git a/pandas/tests/groupby/test_whitelist.py b/pandas/tests/groupby/test_whitelist.py index d5096ee99c8b0..0af0243e6abcf 100644 --- a/pandas/tests/groupby/test_whitelist.py +++ b/pandas/tests/groupby/test_whitelist.py @@ -14,35 +14,15 @@ AGG_FUNCTIONS_WITH_SKIPNA = ['skew', 'mad'] df_whitelist = [ - 'last', - 'first', - 'mean', - 'sum', - 'min', - 'max', - 'head', - 'tail', - 'cumcount', - 'ngroup', - 'resample', - 'rank', 'quantile', 'fillna', 'mad', - 'any', - 'all', 'take', 'idxmax', 'idxmin', - 'shift', 'tshift', - 'ffill', - 'bfill', - 'pct_change', 'skew', - 'plot', 'hist', - 'median', 'dtypes', 'corrwith', 'corr', @@ -57,35 +37,15 @@ def df_whitelist_fixture(request): s_whitelist = [ - 'last', - 'first', - 'mean', - 'sum', - 'min', - 'max', - 'head', - 'tail', - 'cumcount', - 'ngroup', - 'resample', - 'rank', 'quantile', 'fillna', 'mad', - 'any', - 'all', 'take', 'idxmax', 'idxmin', - 'shift', 'tshift', - 'ffill', - 'bfill', - 'pct_change', 'skew', - 'plot', 'hist', - 'median', 'dtype', 'corr', 'cov', @@ -150,17 +110,8 @@ def test_groupby_whitelist(df_letters, whitelist): def check_whitelist(obj, df, m): # check the obj for a particular whitelist m - # these are aliases so ok to have the alias __name__ - alias = {'bfill': 'backfill', - 'ffill': 'pad', - 'boxplot': None} - gb = obj.groupby(df.letters) - m = alias.get(m, m) - if m is None: - return - f = getattr(type(gb), m) # name From 430d3c149188dd0e83c927ec734410a954b93acd Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 24 Dec 2018 20:34:23 -0800 Subject: [PATCH 3/4] Fixed failing test --- pandas/core/groupby/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/groupby/base.py b/pandas/core/groupby/base.py index 6c9a3279fe430..ebba4a0a9395d 100644 --- a/pandas/core/groupby/base.py +++ b/pandas/core/groupby/base.py @@ -69,7 +69,7 @@ def _gotitem(self, key, ndim, subset=None): # special case to prevent duplicate plots when catching exceptions when # forwarding methods from NDFrames -plotting_methods = frozenset(['hist']) +plotting_methods = frozenset(['plot', 'hist']) common_apply_whitelist = frozenset([ 'quantile', 'fillna', 'mad', 'take', From 3f4689f00a09417d36a5c3a71d67e872446adae0 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 24 Dec 2018 23:19:22 -0800 Subject: [PATCH 4/4] Reverted removal of plot from test case --- pandas/tests/groupby/test_whitelist.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/groupby/test_whitelist.py b/pandas/tests/groupby/test_whitelist.py index 50ae34c563c93..a451acebcdba4 100644 --- a/pandas/tests/groupby/test_whitelist.py +++ b/pandas/tests/groupby/test_whitelist.py @@ -22,6 +22,7 @@ 'idxmin', 'tshift', 'skew', + 'plot', 'hist', 'dtypes', 'corrwith', @@ -45,6 +46,7 @@ def df_whitelist_fixture(request): 'idxmin', 'tshift', 'skew', + 'plot', 'hist', 'dtype', 'corr',