Skip to content
Advertisement

Convert string duration column to seconds

In the dataframe, one of the columns is duration. It was given as a string.

JavaScript

How can I convert this column into seconds?

Advertisement

Answer

Use pd.Timedelta to parse each item:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement