title: One-hot-encoding pandas dataframe features according to a list
body: <p>My intent is to just 1-hot-encode the features in the <code>categorical</code> list. The problem with my code is that it keeps 1-hot-encoding the features that were already encoded in the previous iteration. How can I prevent this from occurring?</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  data = {
      'apples': [3, 2, 0, np.nan, 2],
      'oranges': [0, 7, 7, 2, 7],
      'figs':[1, np.nan, 10, np.nan, 10],
      'key-customer':['N','Y','Y','N','N'],
      'rating':['L','L','H','L','M'],
      'frequent-cust':['Y', 'N', 'N', 'N', 'Y']
  }
  purchases = pd.DataFrame(data)
  purchases = pd.DataFrame(data, index=['June', 'Robert', 'Lily', 'David', 'Bob'])
  print(purchases)
  #one-hot-encode just the features in a given subset
  categorical = ['rating', 'key-customer']
  for item in categorical:
      d = pd.get_dummies(purchases[item], prefix=item)
      purchases = pd.concat([purchases, d], axis=1)
      purchases.drop(columns=item, inplace=True)
  print(purchases)
  </code></pre>