I am trying to figure out how to loop through columns to replace its values.
My dataset looks like this:
In this example, I want to replace the decimal comma of the first two columns with decimal points.
When trying to use a for loop like
for col in opel_Df[['Altitude Variation', 'Vehicle Speed Instantaneous']]:
opel_Df[col] = opel_Df[col].replace(',', '.')
nothing happens, but this is because I have to set inplace=True
, but when I do so, I get none
values:
How can I do it?
CodePudding user response:
I would do:
col = ['Altitude Variation', 'Vehicle Speed Instantaneous']
opel_Df[col] = opel_Df[col].replace(',', '\.', regex=True)