I want to check if the date1 column is less than the other date2 column, then create a new column or New Column and assign 1, 0 otherwise. If the calculation is NaT then save NaT to the newly created column. Here is my trial.
if df['date1'] < df['date2'] == True:
df['New Column'] = '1'
elif df['date1'] < df['date2'] == 'NaT':
df['New Column'] = 'NaT'
else:
df['New Column'] = '0'
But this does not seem to work and throwing ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). I am still learning Python and any help on this would be really appreciated.
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire