Skip to content

Commit 725b7a5

Browse files
author
Matt Hagy
committed
Revise attribute/method consistency check to skip known inconsistencies
1 parent 099168f commit 725b7a5

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

pandas/tests/groupby/test_groupby.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5030,13 +5030,44 @@ def test_groupby_whitelist(self):
50305030
# 'nlargest', 'nsmallest',
50315031
])
50325032

5033+
# TODO: Fix these inconsistencies between attribute and method names
5034+
inconsistently_named = frozenset([
5035+
'tshift',
5036+
'any',
5037+
'dtypes',
5038+
'idxmax',
5039+
'all',
5040+
'fillna',
5041+
'rank',
5042+
'quantile',
5043+
'cummax',
5044+
'take',
5045+
'corr',
5046+
'cummin',
5047+
'diff',
5048+
'plot',
5049+
'pct_change',
5050+
'skew',
5051+
'hist',
5052+
'bfill',
5053+
'cov',
5054+
'boxplot',
5055+
'describe',
5056+
'corrwith',
5057+
'idxmin',
5058+
'ffill',
5059+
'mad',
5060+
'dtype',
5061+
'unique'
5062+
])
5063+
50335064
for obj, whitelist in zip((df, s), (df_whitelist, s_whitelist)):
50345065
gb = obj.groupby(df.letters)
50355066
self.assertEqual(whitelist, gb._apply_whitelist)
50365067
for m in whitelist:
50375068
f = getattr(type(gb), m)
5038-
# TODO: Fix inconsistencies between attribute and method names
5039-
# self.assertEqual(f.__name__, m)
5069+
if m not in inconsistently_named:
5070+
self.assertEqual(f.__name__, m)
50405071

50415072
AGG_FUNCTIONS = ['sum', 'prod', 'min', 'max', 'median', 'mean', 'skew',
50425073
'mad', 'std', 'var', 'sem']
@@ -5139,12 +5170,6 @@ def test_tab_completion(self):
51395170
'ffill', 'bfill', 'pad', 'backfill', 'rolling', 'expanding'])
51405171
self.assertEqual(results, expected)
51415172

5142-
def test_groupby_function_rename(self):
5143-
grp = self.mframe.groupby(level='second')
5144-
for name in ['sum', 'prod', 'min', 'max', 'first', 'last']:
5145-
f = getattr(grp, name)
5146-
self.assertEqual(f.__name__, name)
5147-
51485173
def test_lexsort_indexer(self):
51495174
keys = [[nan] * 5 + list(range(100)) + [nan] * 5]
51505175
# orders=True, na_position='last'

0 commit comments

Comments
 (0)