I have some dirty data that I would like to cleanse by converting the incorrect values to the mean. I currently have the following code;
def convert_bad_data(x):
if x < 16:
x == np.mean
return x
elif x > 80:
x == np.mean
return x
else:
return x
When I run this I get the following error
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
The thing is I am not looking to use a boolean so am not sure why I am getting an error about a truth value.