Skip to content

Conversation

@ueshin
Copy link
Collaborator

@ueshin ueshin commented Apr 16, 2020

Adding unique function to SeriesGroupBy.

E.g.,

>>> df = ks.DataFrame({'a': [1, 1, 1, 2, 2, 2, 3, 3, 3],
...                    'b': [1, 2, 2, 2, 3, 3, 3, 4, 4]}, columns=['a', 'b'])
>>> df.groupby(['a'])['b'].unique().sort_index()  # doctest: +SKIP
a
1    [1, 2]
2    [2, 3]
3    [3, 4]
Name: b, dtype: object

Resolves #875.

@ueshin ueshin requested a review from HyukjinKwon April 16, 2020 01:49
3 [3, 4]
Name: b, dtype: object
"""
return self._reduce_for_stat_function(F.collect_set, only_numeric=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh haha I didn't know it can be simple like this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised too while I was investigating. haha

Returns
-------
Index without deuplicates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe deuplicates -> duplicates ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, sorry - I missed this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna include this fixing to #1412 my yet unmerged PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, thanks!

@HyukjinKwon HyukjinKwon merged commit a42af49 into databricks:master Apr 16, 2020
@ueshin ueshin deleted the unique branch April 16, 2020 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SeriesGroupBy.unique

3 participants