I have a following problem. I am doing association rules mining using efficient_apriori package in python. I would like to save my rules as pandas data frame. See my code:
for rule in rules:
dict = {
"left" : [str(rule.lhs).replace(",)",")")],
"right" : [str(rule.rhs).replace(",)",")")],
"support" : [str(rule.support)],
"confidence" : [str(rule.confidence)]
}
df = pd.DataFrame.from_dict(dict)
Is there a better way than this?
# this output after print(rule)
{Book1} -> {Book2} (conf: 0.541, supp: 0.057, lift: 4.417, conv: 1.914)
# this output after print(type(rule))
<class 'efficient_apriori.rules.Rule'>