0

hoping you can help me solve this one. I am working on a project which involves tracking lapse time between when an order is placed and when it's delivered. The date formats of the file I'm working with is as follows: "Calendar Day :hour:minute:second"

That said, I was able to create datetime64[ns] objects for the attributes using the following code:

df["Customer placed order datetime"] = pd.to_datetime(data["Customer placed order datetime"], format='%d %H:%M:%S')
data["Delivered to consumer datetime"] = pd.to_datetime(data["Delivered to consumer datetime"], format='%d %H:%M:%S')

I am then taking the difference of when an order is delivered - when it was placed to get the total time lapse

data["lapse"] = data["Delivered to consumer datetime"] - data["Customer placed order datetime"]

This works great for orders delivered the same day, however I am running into a problem with orders placed late at night and delivered the next day. Please see example below:

Customer placed order | datetime Delivered to consumer datetime | lapse

1900-01-31 23:59:46 | 1900-01-01 01:49:07 | 31 days +01:49:21

Any suggestions on how to fix this issue?

Thanks!

1 Answers1

0

The example provided doesn't reflect the problem you are trying to solve. The dates in the example are a month apart from one another. Try to recreate the error using a valid example and see if the issue still persists

alecbeau
  • 31
  • 1
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 25 '22 at 23:03