0

I have two columns in a dataframe in the format that it contains date and time as well. I need to find the difference in hours. When I try its giving type error.

Error: TypeError: unsupported operand type(s) for -: 'str' and 'str'.

Data example:

D1: 12/26/2014 7:45
    12/31/2014 6:30
D2: 1/1/2015 2:18
    1/1/2015 2:49

Need to find difference as D1-D2

1

1 Answer 1

1

str function doesn't support it, you need to turn it into datetime format, look up about datetime module in python

official documentation: https://docs.python.org/3/library/datetime.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.