Skip to content

Commit 25f946b

Browse files
author
Matt Hagy
committed
Revise attribute/method consistency check to skip known inconsistencies
1 parent d466105 commit 25f946b

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

pandas/tests/test_groupby.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5986,13 +5986,44 @@ def test_groupby_whitelist(self):
59865986
# 'nlargest', 'nsmallest',
59875987
])
59885988

5989+
# TODO: Fix these inconsistencies between attribute and method names
5990+
inconsistently_named = frozenset([
5991+
'tshift',
5992+
'any',
5993+
'dtypes',
5994+
'idxmax',
5995+
'all',
5996+
'fillna',
5997+
'rank',
5998+
'quantile',
5999+
'cummax',
6000+
'take',
6001+
'corr',
6002+
'cummin',
6003+
'diff',
6004+
'plot',
6005+
'pct_change',
6006+
'skew',
6007+
'hist',
6008+
'bfill',
6009+
'cov',
6010+
'boxplot',
6011+
'describe',
6012+
'corrwith',
6013+
'idxmin',
6014+
'ffill',
6015+
'mad',
6016+
'dtype',
6017+
'unique'
6018+
])
6019+
59896020
for obj, whitelist in zip((df, s), (df_whitelist, s_whitelist)):
59906021
gb = obj.groupby(df.letters)
59916022
self.assertEqual(whitelist, gb._apply_whitelist)
59926023
for m in whitelist:
59936024
f = getattr(type(gb), m)
5994-
# TODO: Fix inconsistencies between attribute and method names
5995-
# self.assertEqual(f.__name__, m)
6025+
if m not in inconsistently_named:
6026+
self.assertEqual(f.__name__, m)
59966027

59976028
AGG_FUNCTIONS = ['sum', 'prod', 'min', 'max', 'median', 'mean', 'skew',
59986029
'mad', 'std', 'var', 'sem']
@@ -6095,12 +6126,6 @@ def test_tab_completion(self):
60956126
'ffill', 'bfill', 'pad', 'backfill', 'rolling', 'expanding'])
60966127
self.assertEqual(results, expected)
60976128

6098-
def test_groupby_function_rename(self):
6099-
grp = self.mframe.groupby(level='second')
6100-
for name in ['sum', 'prod', 'min', 'max', 'first', 'last']:
6101-
f = getattr(grp, name)
6102-
self.assertEqual(f.__name__, name)
6103-
61046129
def test_lexsort_indexer(self):
61056130
keys = [[nan] * 5 + list(range(100)) + [nan] * 5]
61066131
# orders=True, na_position='last'

0 commit comments

Comments
 (0)