I'm following a tutorial for a market basket analysis. all works well but I want to export the data to a csv with only text and numbers.
the output of the csv looks something like this
,antecedents,consequents,antecedent support,consequent support,support,confidence,lift,leverage,conviction
0,frozenset({'DOLLY GIRL LUNCH BOX'}),frozenset({'SPACEBOY LUNCH BOX'}),0.22,0.28,0.21,0.95,3.41,0.148,15.84
1,frozenset({'SPACEBOY LUNCH BOX'}),frozenset({'DOLLY GIRL LUNCH BOX'}),0.28,0.22,0.21,0.75,3.41,0.15,3.12
It should look like this
antecedents,consequents,antecedent support,consequent support,support,confidence,lift,leverage,conviction
SPACEBOY LUNCH BOX,DOLLY GIRL LUNCH BOX,0.28,0.22,0.21,0.75,3.41,0.15,3.12
DOLLY GIRL LUNCH BOX,SPACEBOY LUNCH BOX,0.22,0.28,0.21,0.96,3.41,0.1484,15.84
I want to get rid of the frozenset({}) parts of the text
Is this possible in pandas our should I deconstruct and reconstruct the dataframe with str.strip?
df['antecedents'] = df['antecedents'].str.strip('({})')
df['consequents'] = df['consequents'].str.strip('({})')