1

I have a dataframe df:

        workhours
0       0 days 01:45:13.250000000
1       0 days 04:23:56.723404255
2       0 days 07:11:01.688888888
3       0 days 06:02:48.160000000
4       0 days 06:27:57.280000000
5       0 days 07:00:26.551020408
6       0 days 09:04:01.039215686
7       0 days 08:50:11.941176470
8       0 days 07:30:59.725490196
...

And I just want to have the hours and not the "= days". How can I delete this from each row?

Melli
  • 65
  • 6

1 Answers1

0

Try this one:

import re

df["workhours"] = df["workhours"].apply(lambda x: re.sub("\d+ days ", "", x))
Grzegorz Skibinski
  • 12,624
  • 2
  • 11
  • 34