# Groupby key with None value

**URL:** <https://discuss.ray.io/t/groupby-key-with-none-value/15418>\
**Category:** Ray Data\
**Created:** [August 1, 2024, 3:07pm UTC](https://discuss.ray.io/t/groupby-key-with-none-value/15418 "2024-08-01T15:07:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PieReissyet](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/piereissyet/32/6374_2.png) [@PieReissyet](https://discuss.ray.io/u/PieReissyet)\
**Post date:** [August 1, 2024, 3:07pm UTC](https://discuss.ray.io/t/groupby-key-with-none-value/15418/1 "2024-08-01T15:07:04Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- High: It blocks me to complete my task.

Hello, I have been trying to do something pretty straight forward operations when it comes to dataset manipulations but I am failing at doing something efficient with Ray API and would love to have some feedback / help on this task.  
I have reduce my code to this piece so that it can be easily reproducible

> from ray.data.aggregate import AggregateFn  
> from ray.data.preprocessors.imputer import SimpleImputer  
> aggregate = AggregateFn(  
> init=lambda column: ,  
> # accumulate\_row=check\_accumulate,  
> accumulate\_row=lambda a, r: a + [r[‘title’]],  
> # merge=check\_merge,  
> merge=lambda a1, a2: a1 + a2,  
> name=‘title\_grp’  
> )  
> count\_err = 0  
> data = {  
> “category”: [‘A’, ‘A’, ‘A’, ‘B’, ‘B’, ‘B’],  
> “sub\_cat”: [‘a1’, ‘a1’, ‘a2’, ‘b1’, None, ‘b3’],  
> “title”: [f’tit{i}’ for i in range(6)],  
> #“value”: [1, 2, 3, 4, 5, 6]  
> }  
> df = pd.DataFrame(data)  
> ray.data.from\_pandas(df).groupby([‘category’, ‘sub\_cat’]).aggregate(aggregate).take()

This crashed since we have a None value in column title, is this expected ? What’s the workaround you would advise in this example ?

I tried adding preprocessor like so

> preprocessor = SimpleImputer(  
> columns=[“sub\_cat”],  
> strategy=“constant”,  
> fill\_value=“”)

But performances were super super slow on huge volume of data (10M+).  
What would you suggest in this use case ?

Thanks for the great work
