I am trying to remove all non-number values from a specific column using pandas:
(a) I want to change all the last column values to float. There are some non-zero numeric values in the column that I want to preserve as floats.
(b) If non-numeric values exist, I want to replace them all to 0.0 (float). For example, in line 247, the last column has "a", I would like to change it to 0.0.
I have tried:
def isnumber(x):
try:
float(x)
return True
except:
return False
df = pd.read_csv(filename)
df = df[clean_up.applymap(isnumber)]
This however changes every column:

