Skip to content
Advertisement

How do i df.fillna with category median values

I have a large dataset ~1mln rows, and about 5000 absent coordinates(i’d like to fill them with median value by category ‘city’everything but fillna is working, how to make it happen?

JavaScript

Advertisement

Answer

You could do:

JavaScript

First groupby with the city, then use transform with fillna and calculate the median. (you could use any mathematical operation)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement