title: Combine category codes from two different DataFrames and then apply it as a column to each DataFrame
body: <p>I am playing with the famous Titanic dataset.</p>
  <p>I have the <code>train.csv</code> and <code>test.csv</code> loaded into an array of size two called <code>combined</code>. and concatenated the <code>Ticket</code> column of each like this:</p>
  <p><code>all_tickets = combined[0]['Ticket'].append(combined[1]['Ticket'])</code></p>
  <p>Now, my goal is to apply the same categorical codes to each DataFrame. However, when I tried this for the first one:</p>
  <p><code>combined[0]['TicketCode'] = all_tickets.astype('category').cat.codes</code></p>
  <p>It complained: <code>cannot reindex from a duplicate axis</code></p>
  <p>It makes sense since both sets are from different sizes. How can I achieve my goal in this situation? Grouping the Tickets with a range enumerator?</p>
  <p>Thanks</p>