【发布时间】:2022-11-20 00:43:36
【问题描述】:
我正在尝试应用该功能来申请多个数据帧。我为数据框创建了一个列表。如果排名小于 100,高性能列将从排名列复制的值分配,如果排名在 100 和 200 之间,平均列将分配从排名列复制的值。如果排名介于 200 和 300 之间,则性能较低的列将从排名列中复制分配的值。运行脚本时没有收到任何错误消息,但该函数未应用于数据框。任何的意见都将会有帮助。
for file in tests: #tests would be a list of data frame
def func (file):
if (file['ranking']) < 100:
(file['ranking']) == (file['High Performance'])
elif (file['ranking']) > 100 & (file['ranking'] < 200):
(file['ranking'])== (file['Average'])
elif (file ['ranking']) > 200& (file['ranking'] < 300):
(file['ranking']) == (file ['Low Performance'])
else:
return ''
file['High Performance'] = file.apply(func, axis=1)
file['Average'] = file.apply(functionss, axis=1)
file['Low Performance'] = file.apply(functionss, axis=1)
【问题讨论】: