79481887

Date: 2025-03-03 18:53:02
Score: 0.5
Natty:
Report link

This is a typing issue - you just need to convert them to date time and then you can do the date math...

df["Date/Time Opened"] = pd.to_datetime(df["Date/Time Opened"])
df["Date/Time Closed"] = pd.to_datetime(df["Date/Time Closed"])

df["Duration (hours)"] = (df["Date/Time Closed"] - df["Date/Time Opened"]).dt.total_seconds() / 3600

Dates are stored in seconds, so the divide by 3600 is simply converting the seconds of the datetime fields into days in this instance.

Make sense?

Reasons:
  • Has code block (-0.5):
  • Ends in question mark (2):
  • High reputation (-1):
Posted by: Nate