I have a python data-frame in which there are some outlier values. I would like to replace them with the median values of the data, had those values not been there.
id Age
10236 766105
11993 288
9337 205
38189 88
35555 82
39443 75
10762 74
33847 72
21194 70
39450 70
So, I want to replace all the values > 75 with the median value of the dataset of the remaining dataset, i.e., the median value of 70,70,72,74,75
.
I'm trying to do the following:
- Replace with 0, all the values that are greater than 75
- Replace the 0s with median value.
But somehow, the below code not working
df['age'].replace(df.age>75,0,inplace=True)