I'm trying to subtract column df['date_of_admission'] from the column df['DOB'] to find the difference between then and store the age value in df['age'] column, however, I'm getting this error:
OverflowError: Overflow in int64 addition
DOB date_of_admission age
2000-05-07 2019-01-19 12:26:00
1965-01-30 2019-03-21 02:23:12
NaT 2018-11-02 18:30:10
1981-05-01 2019-05-08 12:26:00
1957-01-10 2018-12-31 04:01:15
1968-07-14 2019-01-28 15:05:09
NaT 2018-04-13 06:20:01
NaT 2019-02-15 01:01:57
2001-02-10 2019-03-21 08:22:00
1990-03-29 2018-11-29 03:05:03
..... ......
..... .....
..... .....
I've tried it with the following:
import numpy as np
import pandas as pd
from datetime import dt
df['age'] = (df['date_of_admission'] - df['DOB']).dt.days // 365
Expected to get the following age column after finding the difference between:
age
26
69
NaN
58
.
.
.