Python 减去日期列和今天时出现日期错误';日期

Python 减去日期列和今天时出现日期错误';日期,python,pandas,dataframe,Python,Pandas,Dataframe,我试图从日期列中减去今天的日期: pd.to_datetime(df['Date'])-datetime.datetime.now().date() 但是得到一个错误: TypeError: unsupported operand type(s) for -: 'DatetimeInde' and 'datetime.date' 当前datetime以datetime对象的形式出现,找到要获取的数据类型,转换为datetime格式,如果str转换为datetime,您可以参考下面的链接 干

我试图从日期列中减去今天的日期:

pd.to_datetime(df['Date'])-datetime.datetime.now().date()
但是得到一个错误:

TypeError: unsupported operand type(s) for -: 'DatetimeInde' and 'datetime.date'

当前datetime以datetime对象的形式出现,找到要获取的数据类型,转换为datetime格式,如果str转换为datetime,您可以参考下面的链接


干杯这回答了你的问题吗?