0

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.

  • need example for answer -> https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Panda Kim Nov 10 '22 at 01:38
  • Is this what you're looking for: https://stackoverflow.com/questions/55319655/pandas-how-to-replace-zero-values-in-a-column-with-the-mean-of-that-column-for – crx91 Nov 10 '22 at 01:48

0 Answers0