Skip to content

Commit b40f4a2

Browse files
WillAydPingviinituutti
authored andcommitted
Groupby Whitelist Cleanup (pandas-dev#23972)
1 parent fc4c580 commit b40f4a2

File tree

2 files changed

+7
-67
lines changed

2 files changed

+7
-67
lines changed

pandas/core/groupby/base.py

+7-20
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,22 @@ def _gotitem(self, key, ndim, subset=None):
6969

7070
# special case to prevent duplicate plots when catching exceptions when
7171
# forwarding methods from NDFrames
72-
plotting_methods = frozenset(['plot', 'boxplot', 'hist'])
72+
plotting_methods = frozenset(['plot', 'hist'])
7373

7474
common_apply_whitelist = frozenset([
75-
'last', 'first',
76-
'head', 'tail', 'median',
77-
'mean', 'sum', 'min', 'max',
78-
'cumcount', 'ngroup',
79-
'resample',
80-
'rank', 'quantile',
81-
'fillna',
82-
'mad',
83-
'any', 'all',
84-
'take',
85-
'idxmax', 'idxmin',
86-
'shift', 'tshift',
87-
'ffill', 'bfill',
88-
'pct_change', 'skew',
89-
'corr', 'cov', 'diff',
75+
'quantile', 'fillna', 'mad', 'take',
76+
'idxmax', 'idxmin', 'tshift',
77+
'skew', 'corr', 'cov', 'diff'
9078
]) | plotting_methods
9179

9280
series_apply_whitelist = ((common_apply_whitelist |
9381
{'nlargest', 'nsmallest',
9482
'is_monotonic_increasing',
95-
'is_monotonic_decreasing'}) -
96-
{'boxplot'}) | frozenset(['dtype', 'unique'])
83+
'is_monotonic_decreasing'})
84+
) | frozenset(['dtype', 'unique'])
9785

9886
dataframe_apply_whitelist = ((common_apply_whitelist |
99-
frozenset(['dtypes', 'corrwith'])) -
100-
{'boxplot'})
87+
frozenset(['dtypes', 'corrwith'])))
10188

10289
cython_transforms = frozenset(['cumprod', 'cumsum', 'shift',
10390
'cummin', 'cummax'])

pandas/tests/groupby/test_whitelist.py

-47
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,16 @@
1414
AGG_FUNCTIONS_WITH_SKIPNA = ['skew', 'mad']
1515

1616
df_whitelist = [
17-
'last',
18-
'first',
19-
'mean',
20-
'sum',
21-
'min',
22-
'max',
23-
'head',
24-
'tail',
25-
'cumcount',
26-
'ngroup',
27-
'resample',
28-
'rank',
2917
'quantile',
3018
'fillna',
3119
'mad',
32-
'any',
33-
'all',
3420
'take',
3521
'idxmax',
3622
'idxmin',
37-
'shift',
3823
'tshift',
39-
'ffill',
40-
'bfill',
41-
'pct_change',
4224
'skew',
4325
'plot',
4426
'hist',
45-
'median',
4627
'dtypes',
4728
'corrwith',
4829
'corr',
@@ -57,35 +38,16 @@ def df_whitelist_fixture(request):
5738

5839

5940
s_whitelist = [
60-
'last',
61-
'first',
62-
'mean',
63-
'sum',
64-
'min',
65-
'max',
66-
'head',
67-
'tail',
68-
'cumcount',
69-
'ngroup',
70-
'resample',
71-
'rank',
7241
'quantile',
7342
'fillna',
7443
'mad',
75-
'any',
76-
'all',
7744
'take',
7845
'idxmax',
7946
'idxmin',
80-
'shift',
8147
'tshift',
82-
'ffill',
83-
'bfill',
84-
'pct_change',
8548
'skew',
8649
'plot',
8750
'hist',
88-
'median',
8951
'dtype',
9052
'corr',
9153
'cov',
@@ -150,17 +112,8 @@ def test_groupby_whitelist(df_letters, whitelist):
150112
def check_whitelist(obj, df, m):
151113
# check the obj for a particular whitelist m
152114

153-
# these are aliases so ok to have the alias __name__
154-
alias = {'bfill': 'backfill',
155-
'ffill': 'pad',
156-
'boxplot': None}
157-
158115
gb = obj.groupby(df.letters)
159116

160-
m = alias.get(m, m)
161-
if m is None:
162-
return
163-
164117
f = getattr(type(gb), m)
165118

166119
# name

0 commit comments

Comments
 (0)