I have a dataset with a string column. I'm searching to replace comma with dot, but when i use str.replace method, for some rows (maybe for integer values), it return NaN values.
df['code_input'] = df['code_input'].str.replace(',', '.')
How can i do it?
Example of my desidered dataset:
code_input | desidered_code_output |
---|---|
15.5C72HT | 15.5C72HT |
46,3C8,4HTT | 46.3C8.4HTT |
40 | 40 |
... | ... |
Example of my desidered with str.replace method:
code_input | desidered_code_output |
---|---|
15.5C72HT | 15.5C72HT |
46,3C8,4HTT | 46.3C8.4HTT |
40 | NaN |
... | ... |