Skip to content
Advertisement

How to subtract date and time in Pandas?

I have data from Pandas which was the contents of a CSV file:

JavaScript

I aim to convert the column Date from timestamps to time periods in units of minutes, which should result in something like the following:

JavaScript

Advertisement

Answer

You can use subtract the first timestampe to calculate the difference, then get total_seconds() and convert to minutes:

JavaScript

Output:

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