Need to do further operations on an immutable frozen set in a pandas dataframe

346 views Asked by At

I am trying to do a join on two pandas dataframes, one of which is the result of running an Apriori algorithm from the mlxtend package. When I tried joining the two, it outputted a bunch of None's. I think that at least one of the reasons for this is that one of the dataframes by which I am joining contains "(" and ")" in two of the columns and I have attempted to remove them with no luck because they are immutable frozen sets.

I am going to try to replicate a minimum sample from both dataframes here:

here is a sample of the one data frame:

cat_num             description                     code
(32934-082)         FILTER PAPER #413 75MM 100/PK   2006101
(32934-082)         BULB- 20W HALOGEN (12V)         2099804

and here is a sample of the other:

antecedants consequents support confidence  lift
(32934-082) (32934-080) 0.0124  0.629032    43.682796
(32934-080) (32934-082) 0.0144  0.541667    43.682796

The final result I would like to see is:

description                    hier_code     antecedents consequents supp
FILTER PAPER #413 75MM 100/PK  2006101       32934-082   32934-080 0.0124
BULB- 20W HALOGEN (12V)        2099804       32934-080   32934-082 0.0144

When I do the join's it shows me NaN for all the rows in the columns even know I know they should all have matches. I converted to a string to try to see if I can potentially do a join in this way using

rules.antecedants = rules.antecedants.apply(np.str) but it gave me output that looks like:

antecedent                 consequent
frozenset(['32934-082'])   frozenset(['32934-080'])

so I see that I have an immutable Frozenset that I can't easily breakup. What can I do in order to be able to properly join the two tables?

0

There are 0 answers