In a dataframe, I want to append a column through an if statement as follows:
death_flag = []
For entry in
range(len(demographics)):
if pd.isnull(df['DOD'] [entry]) == False:
if [(df['DOD']-df['DOA'] > pd.Timedelta(days=365) == True)]:
death_flag.append(1)
Df is a dataframe with 'DOD' and 'DOA' as datetime format. I'm aware that in the dataframe they are considered as series. How do I solve this issue ?
The error keeps showing "The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()" For this line “ if [(df['DOD']-df['DOA'] > pd.Timedelta(days=365) == True)]:”