File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -3354,12 +3354,16 @@ def _nunique(self, skipna=True):
3354
3354
:class:`pandas .Series`
3355
3355
If By groups are specified.
3356
3356
'''
3357
- distinct_table = self ._retrieve ('simple.distinct' , includeMissing = not skipna )['Distinct' ]
3358
- # Reduce table to a Series based off the NDistinct column
3359
- distinct_table = distinct_table .set_index ('Column' ).loc [:,'NDistinct' ].astype ('int64' )
3360
- # Strip names from Series to match pandas nunique
3361
- distinct_table .index .name = None
3362
- distinct_table .name = None
3357
+ #If we have a groupby table, we need to consider that
3358
+ if self .get_groupby_vars :
3359
+ return self ._retrieve ('simple.distinct' , includeMissing = not skipna )
3360
+ else :
3361
+ distinct_table = self ._retrieve ('simple.distinct' , includeMissing = not skipna )['Distinct' ]
3362
+ # Reduce table to a Series based off the NDistinct column
3363
+ distinct_table = distinct_table .set_index ('Column' ).loc [:,'NDistinct' ].astype ('int64' )
3364
+ # Strip names from Series to match pandas nunique
3365
+ distinct_table .index .name = None
3366
+ distinct_table .name = None
3363
3367
3364
3368
return distinct_table
3365
3369
You can’t perform that action at this time.
0 commit comments