I want to replace all numerical values less than 120 with an average value calculated from same column in csv. I imported a CSV file as pd and got a complete table. to call the data frame I write data then I get the data file. to call one column I write data.steam and to calculate average value for the column I write average_steam=data.steam.mean() then print average_steam which returns 123. So, I want all values in column steam less than 120 to be replaced by 123. i.e if I have 12, 90, 130, 128,110 I want to get 123,123,130,128, 123. All necessary libraries are imported.
The code I tried:
data.steam
average_steam=data.steam.mean()
print average_steam
data.steamin.replace(data.steamin<=120,average_steam, inplace=True)