Back
In my df, I have some of the values set up as the dtype(str)
x 27:47 13:45 10:45
x
27:47
13:45
10:45
And I would like to convert them to a float, ending up with:
x 27.47 13.45 10.45
27.47
13.45
10.45
How do I do this?
In your case, you can do this:
df['x'] = df['x'].str.replace(':','.').astype(float)
Output:
x0 27.471 13.452 10.45
0 27.47
1 13.45
2 10.45
If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch
31k questions
32.8k answers
501 comments
693 users