I have a dataset with two columns column1 = radius and column2 = fruit radius = 10,2,3,0,10,2,0,12,6,10 fruits = apple,apple,mango,watermelon, watermelon, apple, mango, watermelon, mango, apple
I want to write a function that find the values with zero and replace it with the mean value of that fruit class using pandas/python. For example If the apple has 0 value in radius column. That zero has to be replaced with mean value of apple values not considering watermelon and mango values.
I tried df.mean() but I want for individual class name.