koalas icon indicating copy to clipboard operation
koalas copied to clipboard

ks.groupby won't drop groups with one or more null keys

Open pandareen opened this issue 7 years ago • 7 comments

This is basically where the pandas groupby adopts its behaviour from r. I can submit a pr if this is not on anyones roadmap

pandareen avatar Nov 05 '19 13:11 pandareen

pyspark doesn't drop null groups. I didn't know this.

>>> sdf.show()
+----+
|   x|
+----+
|null|
| 1.0|
| 1.0|
+----+

>>> sdf.groupBy('x').count().show()
+----+-----+
|   x|count|
+----+-----+
|null|    1|
| 1.0|    2|
+----+-----+

>>> sdf.toPandas().groupby('x').agg({'x': 'count'})
     x
x	
1.0  2

harupy avatar Nov 05 '19 13:11 harupy

@harupy correct. That is to keep it consistent with r library

pandareen avatar Nov 05 '19 14:11 pandareen

Yeah, I noticed this behaviour as well lately. Please go ahead for a PR!

HyukjinKwon avatar Nov 06 '19 02:11 HyukjinKwon

Okay thanks, I'm on it

pandareen avatar Nov 06 '19 16:11 pandareen

Hi, pandas 1.1.0 recently added a dropna parameter in order to allow groupby on null keys. By default (True), null keys are dropped, and it has pyspark behavior when set to False. I think it would be interesting to add it to koalas dataframe groupby method. May i work on it ?

LucasG0 avatar Aug 11 '20 19:08 LucasG0

@LucasG0 Awesome, please go ahead! Thanks! cc @itholic as working on pandas 1.1 support

ueshin avatar Aug 11 '20 20:08 ueshin

Thanks, @LucasG0 . And thanks for the notice, @ueshin

itholic avatar Aug 11 '20 22:08 itholic