code: def generate_itemsets(generator, num_itemsets, colname_map):
      itemsets = []
      supports = []
      for sup, iset in generator:
          itemsets.append(frozenset(iset))
          supports.append(sup / num_itemsets)
  
      res_df = pd.DataFrame({"support": supports, "itemsets": itemsets})
  
      if colname_map is not None:
          res_df["itemsets"] = res_df["itemsets"].apply(
              lambda x: frozenset([colname_map[i] for i in x])
          )
  
      return res_df
  
file_path: mlxtend/mlxtend/frequent_patterns/fpcommon.py
imports: import collections
  import warnings
  import numpy
  import pandas
  from pandas import __version__
label_desc: Use image node_id 2 for calling a global function with example usage: generate_itemsets(generator, num_itemsets, colname_map) and returns: res_df