【发布时间】:2021-12-22 17:30:08
【问题描述】:
这是我的代码:
results=[]
for item in association_results:
pair = item[0]
items = [x for x in pair]
value0 = str(items[0])
value1 = str(items[1])
value2 = str(item[1])[:7]
value3 = str(item[2][0][2])[:7]
value4 = str(item[2][0][3])[:7]
rows = (value0,value1,value2,value3,value4)
results.append(rows)
Labels =['Title1','Title2','Support','Confidence','Lift']
store_suggestion = pd.DataFrame.from_records(results,columns=Labels)
print(store_suggestion)
输出:
Title1 Title2 Support Confidence Lift
0 chicken light cream 0.00453 0.29059 4.84395
Title1 Title2 Support Confidence Lift
0 chicken light cream 0.00453 0.29059 4.84395
1 escalope mushroom cream sauce 0.00573 0.30069 3.79083
Title1 Title2 Support Confidence Lift
0 chicken light cream 0.00453 0.29059 4.84395
1 escalope mushroom cream sauce 0.00573 0.30069 3.79083
2 escalope pasta 0.00586 0.37288 4.70081
Title1 Title2 Support Confidence Lift
0 chicken light cream 0.00453 0.29059 4.84395
1 escalope mushroom cream sauce 0.00573 0.30069 3.79083
2 escalope pasta 0.00586 0.37288 4.70081
3 herb & pepper ground beef 0.01599 0.32345 3.29199
Title1 Title2 Support Confidence Lift
0 chicken light cream 0.00453 0.29059 4.84395
1 escalope mushroom cream sauce 0.00573 0.30069 3.79083
2 escalope pasta 0.00586 0.37288 4.70081
3 herb & pepper ground beef 0.01599 0.32345 3.29199
4 tomato sauce ground beef 0.00533 0.37735 3.8406
但我想以下列方式呈现结果: enter image description here
实际上我不太明白我的代码是什么意思。谁能给我解释一下?谢谢。
【问题讨论】: