Issue
I have two columns date1 and date2 in 2/23/2022 12:30:26
format ,i want to calculate difference in hours. How to implement .
Solution
You can convert two columns to datetime type then subtract at last get hours from timedelta object.
df['date1'] = pd.to_datetime(df['date1'])
df['date2'] = pd.to_datetime(df['date2'])
df['diff'] = (df['date1']-df['date2']) / pd.Timedelta(hours=1)
Answered By - Ynjxsjmh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.