title: How to keep transaction number related to association rules created in mlxtend python?
body: <p>The transaction numbers related with the frequent itemsets created are not kept after using the apriori method in mlxtend. They are dropped.</p>
  <p>How can i keep the transaction numbers?</p>
  <pre><code>df = pd.read_csv('association_rule_items_fullmech.csv')
  
  basket = (df.groupby(['transaction_doc', 'text'])['transaction_doc'].sum().unstack().reset_index().fillna(0).set_index('transaction_doc'))
  
  
  # one-hot encoding
  def encode_units(x):
  if x &lt;= 0:
      return 0
  elif x &gt;= 1:
      return 1
  
  basket_sets = basket.applymap(encode_units)
  </code></pre>
  <p>baskets_sets dataframe essentially looks like this (this is just an mini arbitrary example but the same structure):</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>transaction_doc - text</th>
  <th>&quot;string1&quot;</th>
  <th>&quot;string2&quot;</th>
  <th>&quot;string3&quot;</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>1</td>
  <td>0</td>
  <td>1</td>
  </tr>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>1</td>
  <td>0</td>
  </tr>
  <tr>
  <td>2</td>
  <td>0</td>
  <td>0</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>i then apply the apriori function</p>
  <pre><code>frequent_itemsets = apriori(basket_sets, min_support=0.001, use_colnames=True)
  </code></pre>
  <p>however after this apriori funcion, the transaction_doc, which is where the indicator of which document the text comes from, disappears from the the idx column. I get a reseted index column with the frequent itemsets. I want to be able to retain the transaction_doc column after the apriori function is applied.</p>