【发布时间】:2020-03-07 15:49:43
【问题描述】:
数据变量是我计算出的用于对每个输入进行排名的百分比。当我运行此代码时,它返回此错误。 “ValueError:Series 的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。” 请让我知道如何解决此问题或可能的帮助者。
谢谢!!
def create_column(data):
if data <= 1.1175:
grouping = 'not popular'
elif data > 1.1176 and data < 2.235:
grouping = 'Mildly not popular'
elif data > 2.236 and data < 3.3525:
grouping = 'Mild Popularity'
elif data >=4.47:
grouping = 'popular'
else:
grouping = 'Neutral'
return grouping
data = df1['score']
create_column((data))
【问题讨论】:
-
@abdoulsn 我读了一遍,还是有点困惑
-
您能否发布您设置为创建 df1 的数据样本?
-
@oppressionslayer 添加了照片