gpt4 book ai didi

python - 从规则 freezeset 中提取字符串

转载 作者:行者123 更新时间:2023-12-01 01:37:06 31 4
gpt4 key购买 nike

声明如下:

rules = association_rules(frequent_itemsets, metric="lift", min_threshold=1.2) 

我得到了以下格式的规则数据框:

frozenset({'Co_Apples'})

但我需要将 Co_Apples 提取为字符串。

我怎样才能做到这一点?

最佳答案

rules["antecedents"] = rules["antecedents"].apply(lambda x: ', '.join(list(x))).astype("unicode")

这对我来说是工作。谢谢Frank Herfert拯救我的日子!

关于python - 从规则 freezeset 中提取字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52291739/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com