I really need help with this one. My previous post was very bad and unclear - I'm sorry - I wish I could delete but hopefully this one will be better.
I need to calculate the age based off of a date (see ANALYZE section and FINAL OUTCOME SECTION).
ORIGINAL DATA SET
"JOLIE", 09091959,02051983
"PORTMAN",02111979,01272002
"MOORE", 01281975,01182009
"BEST", 04081973,07022008
"MONROE", 04161957,11231979
LOAD DATA
from pandas import DataFrame, read_csv
import matplotlib.pyplot as plt
import pandas as pdcolumns = ['lname','dob','scd_csr_mdy']raw_data = pd.read_csv(r'C:\Users\davidlopez\Desktop\Folders\Standard Reports\HR Reports\eeprofil \eeprofil.txt',` names=columns, parse_dates = ['dob','scd_csr_mdy'})df1 = raw_dataIn [1]: df1
Out [1]:lname dob scd_csr_mdy0 JOLIE 09091959 020519831 PORTMAN 02111979 012720022 MOORE 01281975 011820093 BEST 04081973 070220084 MONROE 04161957 11231979
ANALYZE
I tried doing the following but received an error:
now = datetime.now()
df1['age'] = now - df1['dob']
But I received the the error:
TypeError: unsported operant type(S) for -: 'datetime.datetime' and 'str'
FINAL OUTCOME
lname dob scd_csr_mdy DOB_AGE SCD_AGE
0 JOLIE 09091959 02051983 55 32
1 PORTMAN 02111979 01272002 36 13
2 MOORE 01281975 01182009 40 6
3 BEST 04081973 07022008 42 6
4 MONROE 04161957 11231979 58 35
Any suggestions.....?