【发布时间】:2022-10-05 01:44:14
【问题描述】:
我在熊猫中有这个结果
Antecedent Consequent confidence lift support
0 (3623,) (2568,) 0.829517 13.964925 0.0326
1 (4304,) (4305,) 0.808362 24.348264 0.0232
2 (3623, 3970) (2568,) 0.922581 15.531661 0.0286
和字典df
key name
0 1001 Boombox Ipod Classic
1 1002 USB Office Mirror Ball
我试图通过添加来用字典解释先行词
resultsdf['Antecedent_name'] = resultsdf['Antecedent'].astype(str).map(df)
我收到错误
The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), `a.item(), a.any() or a.all().`
【问题讨论】:
-
您想将另一个名为
'Antecedent_name'的列添加到包含来自df的字典的resultsdf吗? -
是的,我想添加新列问题前件可以有两个值(3623、3970)所以新列应该是(名称,名称)
标签: python dictionary mapping