how to use python panda to implement apriori algorithm how t
how to use python, panda to implement apriori algorithm. 
  
 
   
 how to use python, panda to implement apriori algorithm. 
  
 
   
 Solution
from itertools import combinations
 def get_support(df): pp = []
 for cnum in range(1, len(df.columns)+1):
 for cols in combinations(df, cnum): s = df[list(cols)].all(axis=1).sum() pp.append([\",\".join(cols), s]) sdf = pd.DataFrame(pp, columns=[\"Pattern\", \"Support\"])
 return sdf
After this give in the command line the following argument,
>>> s = get_support(df)
 >>> s[s.Support >= 3]

