Skip to content

Commit 04cf626

Browse files
author
Matt Hagy
committed
Revise attribute/method consistency check to skip known inconsistencies
1 parent 68ca21d commit 04cf626

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

pandas/tests/groupby/test_groupby.py

+33-8
Original file line numberDiff line numberDiff line change
@@ -5213,13 +5213,44 @@ def test_groupby_whitelist(self):
52135213
# 'nlargest', 'nsmallest',
52145214
])
52155215

5216+
# TODO: Fix these inconsistencies between attribute and method names
5217+
inconsistently_named = frozenset([
5218+
'tshift',
5219+
'any',
5220+
'dtypes',
5221+
'idxmax',
5222+
'all',
5223+
'fillna',
5224+
'rank',
5225+
'quantile',
5226+
'cummax',
5227+
'take',
5228+
'corr',
5229+
'cummin',
5230+
'diff',
5231+
'plot',
5232+
'pct_change',
5233+
'skew',
5234+
'hist',
5235+
'bfill',
5236+
'cov',
5237+
'boxplot',
5238+
'describe',
5239+
'corrwith',
5240+
'idxmin',
5241+
'ffill',
5242+
'mad',
5243+
'dtype',
5244+
'unique'
5245+
])
5246+
52165247
for obj, whitelist in zip((df, s), (df_whitelist, s_whitelist)):
52175248
gb = obj.groupby(df.letters)
52185249
self.assertEqual(whitelist, gb._apply_whitelist)
52195250
for m in whitelist:
52205251
f = getattr(type(gb), m)
5221-
# TODO: Fix inconsistencies between attribute and method names
5222-
# self.assertEqual(f.__name__, m)
5252+
if m not in inconsistently_named:
5253+
self.assertEqual(f.__name__, m)
52235254

52245255
AGG_FUNCTIONS = ['sum', 'prod', 'min', 'max', 'median', 'mean', 'skew',
52255256
'mad', 'std', 'var', 'sem']
@@ -5322,12 +5353,6 @@ def test_tab_completion(self):
53225353
'ffill', 'bfill', 'pad', 'backfill', 'rolling', 'expanding'])
53235354
self.assertEqual(results, expected)
53245355

5325-
def test_groupby_function_rename(self):
5326-
grp = self.mframe.groupby(level='second')
5327-
for name in ['sum', 'prod', 'min', 'max', 'first', 'last']:
5328-
f = getattr(grp, name)
5329-
self.assertEqual(f.__name__, name)
5330-
53315356
def test_lexsort_indexer(self):
53325357
keys = [[nan] * 5 + list(range(100)) + [nan] * 5]
53335358
# orders=True, na_position='last'

0 commit comments

Comments
 (0)