0

I am trying to figure out how to loop through columns to replace its values.

My dataset looks like this:

Enter image description here

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:

Enter image description here

How can I do it?

1 Answer 1

0

I would do:

col = ['Altitude Variation', 'Vehicle Speed Instantaneous']

opel_Df[col] = opel_Df[col].replace(',', '\.', regex=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.