我的数据集包含一间公司股票的详细信息。 而且我已经计算了连续2天的股票收盘价变化的百分比,该列称为“ Day_Perc_Change”。我还有一列称为“趋势”的列,需要填充以下约束: “ Day_Perc_Change”的“轻微或无变化”在-0.5和0.5之间 “ Day_Perc_Change”的“轻微正值”介于0.5和1之间 “ Day_Perc_Change”的“轻微否定”值介于-0.5和-1之间 1到3之间的“ Day_Perc_Change”为“正” “ Day_Perc_Change”的“负”值介于-1和-3之间 Day_Perc_Change的“最高获利者”介于3到7之间 -3至-7之间的“ Day_Perc_Change”为“最大输家” 'Day_Perc_Change'> 7的“牛市” “ Day_Perc_Change” <-7
的“跌落”因此我写了一个逻辑
<ul>
<li>
<a class="navigation1">HTML</a>
</li>
<li>
<a class="navigation2">DOM</a>
</li>
<li>
<a class="navigation3">Javascript</a>
</li>
</ul>
我遇到的错误是:
if -0.5<data['Day_Perc_Change']<0.5:
data['Trend'] = 'Slight or No change'
elif 0.5<data['Day_Perc_Change']<1:
data['Trend'] = 'Slight positive'
elif -1<data['Day_Perc_Change']<-0.5:
data['Trend'] = 'Slight negative'
elif 1<data['Day_Perc_Change']<3:
data['Trend'] = 'Positive'
elif -3<data['Day_Perc_Change']<-1:
data['Trend'] = 'Negative'
elif 3<data['Day_Perc_Change']<7:
data['Trend'] = 'Among top gainers'
elif -7<data['Day_Perc_Change']<-3:
data['Trend'] = 'Among top losers'
elif data['Day_Perc_Change']>7:
data['Trend'] = 'Bull run'
else:
data['Trend'] = 'Bear drop'