A pandas DataFrame column duration contains timedelta64[ns] as shown. How can you convert them to seconds?
0 00:20:32
1 00:23:1
Use the Series dt accessor to get access to the methods and attributes of a datetime (timedelta) series.
>>> s
0 -1 days +23:45:14.304000
1 -1 days +23:46:57.132000
2 -1 days +23:49:25.913000
3 -1 days +23:59:48.913000
4 00:00:00.820000
dtype: timedelta64[ns]
>>>
>>> s.dt.total_seconds()
0 -885.696
1 -782.868
2 -634.087
3 -11.087
4 0.820
dtype: float64
There are other Pandas Series Accessors for String, Categorical, and Sparse data types.