📜  pandas 日期之间的差异 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:18.033000             🧑  作者: Mango

代码示例2
# 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