首页  >  问答  >  正文

python - 如何让dataframe中两列时间相减?

ringa_leeringa_lee2741 天前1274

全部回复(1)我来回复

  • ringa_lee

    ringa_lee2017-04-18 10:35:13

    两个字段类型不匹配不能进行运算
    运算之前先转换一下类型

    df['age'] = pd.to_datetime(df['indate']) - pd.to_datetime(df['dob'])

    回复
    0
  • 取消回复