I have this dataset where I would like to calculate the age:
Name DOB
John 1995-12-04
James 1997-10-01
Jacoob 1997-08-30
Hansard 1995-03-12
Yusoft 1992-12-12
Henry 1993-02-12
I have tried this code:
now = pd.Timestamp('now')
df['age'] = (now - df['DOB'])
but I get this error:
*A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead*
i also tried df.loc[df['DOB']] but didnt work