Answers for "datediff pandas"

0

datediff in seconds in pandas

t1 = pd.to_datetime('1/1/2015 01:00')
t2 = pd.to_datetime('1/1/2015 03:30')

print pd.Timedelta(t2 - t1).seconds / 3600.0
Posted by: Guest on January-19-2021
0

python: calculate number of days from today date in a data frame

df[['A','B']] = df[['A','B']].apply(pd.to_datetime) # If conversion required
df['C'] = (df['B'] - df['A']).dt.days
Posted by: Guest on June-22-2020

Python Answers by Framework

Browse Popular Code Answers by Language