This is the code I have written and df is dataframe. I am using python3 and I am new to pandas and I have tried bitwise operator as well as keywords and or
if((df['Day_Perc_Change']>=-0.5) & (df['Day_Perc_Change']<=0.5)):
df['Trend']="Slight or No Change"
elif((df['Day_Perc_Change']>=0.5) & (df['Day_Perc_Change']<=1)):
df['Trend']="Slight Positive"
elif((df['Day_Perc_Change']>=-1) & (df['Day_Perc_Change']<=-0.5)):
df['Trend']="Slight Negative"
elif((df['Day_Perc_Change']>=1) & (df['Day_Perc_Change']<=3)):
df['Trend']="Positive"
elif((df['Day_Perc_Change']>=-3) & (df['Day_Perc_Change']<=-1)):
df['Trend']="Negative"
elif((df['Day_Perc_Change']>=3) & (df['Day_Perc_Change']<=7)):
df['Trend']='Among top gainers'
else:
df['Trend']="Bear drop"
}
**This is the error I am getting
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). I have used both and as well as | but it is working. Can anyone help me out? **