Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

In my df, I have some of the values set up as the dtype(str)

      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

How do I do this?

1 Answer

0 votes
by (36.8k points)

In your case, you can do this:

df['x'] = df['x'].str.replace(':','.').astype(float)

Output:

       x

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

Related questions

Browse Categories

...