@@ -3917,9 +3917,10 @@ def nunique(self, dropna=True):
3917
3917
3918
3918
Examples
3919
3919
--------
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')})
3923
3924
>>> df
3924
3925
id value1 value2
3925
3926
0 spam 1 a
@@ -3936,16 +3937,15 @@ def nunique(self, dropna=True):
3936
3937
ham 1 1 2
3937
3938
spam 1 2 1
3938
3939
3940
+ # check for rows with the same id but conflicting values
3939
3941
>>> df.groupby('id').filter(lambda g: (g.nunique() > 1).any())
3940
3942
id value1 value2
3941
3943
0 spam 1 a
3942
3944
3 spam 2 a
3943
3945
4 ham 5 x
3944
3946
5 ham 5 y
3945
3947
"""
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 ))
3949
3949
3950
3950
3951
3951
from pandas .tools .plotting import boxplot_frame_groupby # noqa
0 commit comments