• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: calculate time spent by subtracting two times

Resolved: calculate time spent by subtracting two times

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a dataframe ‘trades_df’. It has columns, ‘open_time’ and ‘close_time’ in the format 19-08-2020 12:19. I want to make a new column ‘time_spent’ which would be the difference between ‘close_time’ and ‘open_time’. See the photo for reference. enter image description here

Answer:

Your datetimes have days come first, so dayfirst should be True:

If you have better answer, please add a comment about this, thank you!

datetime feature-engineering pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why reference in pointer array doesn’t have data?

24/03/2023

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.