0

How do i change multiple columns to a float when i also need to change , to.

DF looks like this enter image description here except i dropped all the NAN values as i dont need those rows.

This is the dtypes enter image description here

And this is the way im doing it now, but it takes hella long time. I know you can do a loop but i don't understand how. enter image description here

1 Answers1

1

Use df.iloc:

df.iloc[:, 2:] = df.iloc[:, 2:].replace(',', '.', regex=True).astype(float)
Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58