I have defined a function that should add a new column called season to the data frame. The values of season are extracted from the date column:
def season(df):
df['sum'] = ((df['date'].dt.month) * 100) + df['date'].dt.day
df['season'] = np.where(df['sum'] > 320 & df['sum'] < 621, 1, np.where(df['sum'] > 620 & df['sum'] < 923, 2, np.where(df['sum'] > 922 & df['sum'] < 1223, 3, 4)))
df.drop(['sum'], axis=1, inplace=True)
return df
But when I call this function inside the main code, I get this error message:
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Where should be modified?
Thanks.