【发布时间】:2019-12-13 11:20:07
【问题描述】:
下面是当前代码的摘要,我正在尝试将 weight1 和 weight2 的所有值作为一个循环来测试以在函数内部使用,但我得到的结果不正确,请各位大神指教,谢谢
weight1 = 0.95
weight2 = 0.05
while weight1 >= 0.05:
weight1 -= 0.05
while weight2 <= 0.95:
weight2 += 0.05
def mod(dates):
df1['score'] = ((df1['EY_rank'] * weight1) + (df1['ROIC_rank'] * weight2)) / 2
print(result)
for i in dates:
mod(i)
【问题讨论】:
-
您的代码中有
def mod(dates):。这向我表明,您的问题中的缩进不正确。你能解决这个问题吗?
标签: python pandas function while-loop