Входные значения, передаваемые в функцию:
topics = ['Critical','Insight']
themes = ['escalation_fg','process_fg']
причины = ['reason_escalation_fg','reason_process_fg']
l2_themes = ['CRC','Process']
Код: Выделить всё
def set_alert_priority(row, topics, themes, reasons, l2_themes):
num_alerts_tagged = len([c for c in themes if row[c] == 1])
row_sum = sum([row[c] for c in themes])
if num_alerts_tagged == 0:
return ('No Action Taken', 'No Action Taken', 'No Action Taken')
elif row_sum == -25:
return ('GPT Error', 'GPT Error', 'GPT Error')
else:
for topic, theme, reason, l2_theme in zip(topics, themes, reasons, l2_themes):
if row[theme] == 1:
return (topic, l2_theme, row[reason])
inferenced_data[['Level_L1', 'Level_L1', 'Alert_Reason']] = inferenced_data.apply(lambda row : set_alert_priority(row, topics, themes, reasons, l2_themes), axis=1)
Полагаю, это связано с тем, что Метод «применить» не для фрейма данных Spark? Какая может быть альтернатива в данном случае?
Подробнее здесь: https://stackoverflow.com/questions/793 ... -dataframe
Мобильная версия