Answers for "pandas difference between dates"

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
0

pandas difference between dates

# credit to Stack Overflow user in the source link
import pandas as pd 
# df is your pandas dataframe
# if already datetime64 you don't need to use to_datetime

df['A'] = pd.to_datetime(df['A'])
df['B'] = pd.to_datetime(df['B']) 

df['diff'] =  df['A'] - df['B'] # difference in days
Posted by: Guest on September-03-2021

Code answers related to "pandas difference between dates"

Python Answers by Framework

Browse Popular Code Answers by Language