@@ -3917,9 +3917,10 @@ def nunique(self, dropna=True):
39173917
39183918 Examples
39193919 --------
3920- >>> df = DataFrame({'id': ['spam', 'egg', 'egg', 'spam', 'ham', 'ham'],
3921- ... 'value1': [1, 5, 5, 2, 5, 5],
3922- ... 'value2': list('abbaxy')})
3920+ >>> df = pd.DataFrame({'id': ['spam', 'egg', 'egg', 'spam',
3921+ ... 'ham', 'ham'],
3922+ ... 'value1': [1, 5, 5, 2, 5, 5],
3923+ ... 'value2': list('abbaxy')})
39233924 >>> df
39243925 id value1 value2
39253926 0 spam 1 a
@@ -3936,16 +3937,15 @@ def nunique(self, dropna=True):
39363937 ham 1 1 2
39373938 spam 1 2 1
39383939
3940+ # check for rows with the same id but conflicting values
39393941 >>> df.groupby('id').filter(lambda g: (g.nunique() > 1).any())
39403942 id value1 value2
39413943 0 spam 1 a
39423944 3 spam 2 a
39433945 4 ham 5 x
39443946 5 ham 5 y
39453947 """
3946- from functools import partial
3947- func = partial (Series .nunique , dropna = dropna )
3948- return self .apply (lambda g : g .apply (func ))
3948+ return self .apply (lambda g : g .apply (Series .nunique , dropna = dropna ))
39493949
39503950
39513951from pandas .tools .plotting import boxplot_frame_groupby # noqa
0 commit comments