koalas icon indicating copy to clipboard operation
koalas copied to clipboard

SeriesGroupBy.unique

Open ueshin opened this issue 7 years ago • 4 comments

Implement SeriesGroupBy.unique.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.unique.html

ueshin avatar Oct 03 '19 22:10 ueshin

Out of curiosity, what behaviors is expected for SeriesGroupBy.

SeriresGroupBy should be generated by Series.groupby, where parameter by of groupby could be Series or label(s) .

If by is Series, _resolve_col does not allow other Series as index It is not possible to do things like using one series as other's index

k_idx_ser = pd.Series([1,1,1,1,2,2])
kser = pd.Series([1,2,3,4,3,2,1])

kser.groupby(k_idx_ser)

So only thing could do is kser.groupby(kser). If so, the result is same to kser.unique(), just select the distinct item in series

If by is labels, labels in Series is just ['__index_level_0__', '0'] If use label 0, the case is same as above

It looks like in current implementation, output of SeriesGroupBy.unique could only be Series.unique ?

guyao avatar Nov 21 '19 01:11 guyao

Yeah, that should be fixed to allow other Series.

groupby should support columns from a different DataFrame when the option is enabled but seems it's not working for now. I noticed this problem too but couldn't fix it yet.

HyukjinKwon avatar Nov 21 '19 04:11 HyukjinKwon

Hi @HyukjinKwon Can I try working on this ?

raghavansandhya avatar Mar 10 '20 17:03 raghavansandhya

Please go ahead!

HyukjinKwon avatar Mar 11 '20 03:03 HyukjinKwon