Following this thread, Change data type of columns in Pandas (btw I didn't answer on this topic and created a new one as I didn' find a way to ask new questions on an existing, but if I did wrong and should have followed the thread, please let me know how I should do).
I'm working on a pricing tool and reading pricing tables.
Having read a csv with pandas, I'm trying to convert string to float but for specific rows only.
Indeed, I have in the same column both string and float, although they all look like float. For instance, I have ZIPCode, which are to be considered as string, and float number in the same column (for TCC type rows, Value is a float in the example) :
Of course, I have several thousands of lines in my df so I've tried to sum it up.
I've tried the following but this doesn't work:
df.loc[df.loc[:, 'Type'] == 'TCC']['Value'].apply(pd.to_numeric, errors='ignore')
This doesn't work either :
df.loc[df.loc[:, 'Type'] == 'TCC']['Value'] = df.loc[df.loc[:, 'Type'] == 'TCC']['Value'].apply(pd.to_numeric, errors='ignore')
Would you have an idea how to do so ?