Home  >  Q&A  >  body text

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

ringa_leeringa_lee2741 days ago1275

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 10:35:13

    If the two field types do not match, the operation cannot be performed.
    Convert the type before the operation.

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

    reply
    0
  • Cancelreply