Here's my data
Customer_id Date-of-birth
1 1992-07-02
2 1991-07-03
Here's my code
import datetime as dt
df['now'] = dt.datetime.now()
df['age'] = df['now'].dt.date - df['Date-of-birth']
Here's the result
Customer_id Date-of-birth age
1 1992-07-02 xxxx days
2 1991-07-03 xxxx days
The result that I want is
Customer_id Date-of-birth age
1 1992-07-02 26 years 22 days
2 1991-07-03 27 years 21 days
Just let you now, by df.dtypes
, Date-of-birth
is an object because is based on customer input in dropdown
How can I achieve this? I hope the question is clear enough
df['age'][i] = year_days_diff(df['Date-of-Birth'][i])
, or see/use Dahlia's answer ;) – Colner