I have the following df where some values in the df are strings (those with %) while other ones aren't.
test overall
Quents Ratio 270.01% 256.02%
Amount sulphur 0.17 0.19
Amount salt - 20.89
amount silica 4.29% 6.84%
I would like to make all the values numeric given that I would like to carry out some analysis among the 2 columns.
Desired output:
test overall
Quents Ratio 270.01 256.02
Amount sulphur 0.17 0.19
Amount salt - 20.89
amount silica 4.29 6.84
What I have tried is to:
def numeric_df(df):
df_detail=df.loc[['Quents Ratio','amount silica'],:]
df_detail= df_detail.apply(lambda x:str(x)[:-1])
return df
But returns same initial df.
How could I obtain the desired output?
-toNaN?-is string.