How can I calculate the age of a person (based off the dob column) and add a column to the dataframe with the new value?
dataframe looks like the following:
lname fname dob
0 DOE LAURIE 03011979
1 BOURNE JASON 06111978
2 GRINCH XMAS 12131988
3 DOE JOHN 11121986
I tried doing the following:
now = datetime.now()
df1['age'] = now - df1['dob']
But, received the following error:
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…