Skip to content

Commit fbee8e0

Browse files
author
Michael Erickson
committed
Added groupby consideration for no casout
1 parent 43414df commit fbee8e0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

swat/cas/table.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,12 +3354,16 @@ def _nunique(self, skipna=True):
33543354
:class:`pandas .Series`
33553355
If By groups are specified.
33563356
'''
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
33633367

33643368
return distinct_table
33653369

0 commit comments

Comments
 (0)