title: save and load one hot encoding for ML
body: <p>I have been searching for two days now and at seems I cannot grasp the solution. For a machine learning regression model, I need a hot encoding of some columns. The training data and model fitting is happening on my local PC. After this the model will be uploaded to the server for predictions.</p>
  
  <p>The problem is that new data was not part of initial encoding so I need to hot encode it in same way as learning data on my PC. I found out that I can save the encoder (sklearn.preprocessing -> OneHotEncoder).
  But I cannot manage to get the data into the correct format.</p>
  
  <p>To make it easier to understand here I just created a notebook with some very simple dummy data.</p>
  
  <pre><code># Import pandas library 
  import pandas as pd 
  # initialize list of lists 
  data = [['tom', 10], ['nick', 15], ['juli', 14]] 
  # Create the pandas DataFrame 
  df = pd.DataFrame(data, columns = ['Name', 'Age']) 
  # print dataframe.
  df 
  </code></pre>
  
  <p>Output:</p>
  
  <p>Name    Age</p>
  
  <p>tom 10</p>
  
  <p>nick    15</p>
  
  <p>juli    14</p>
  
  <hr>
  
  <pre><code># hot encoding
  hot_Name = pd.get_dummies(df.Name)
  X = pd.concat((df[['Age']], hot_Name), axis=1)
  X
  </code></pre>
  
  <p>Output:</p>
  
  <p>Age juli    nick    tom</p>
  
  <p>10  0   0   1</p>
  
  <p>15  0   1   0</p>
  
  <p>14  1   0   0</p>
  
  <hr>
  
  <pre><code># outside data
  # initialize list of lists 
  data_new = [['michael', 20], ['juli', 45]] 
  # Create the pandas DataFrame 
  df_new = pd.DataFrame(data_new, columns = ['Name', 'Age']) 
  # print dataframe. 
  df_new
  </code></pre>
  
  <p>Output:</p>
  
  <p>Name    Age</p>
  
  <p>michael 20</p>
  
  <p>juli    45</p>
  
  <p>Is it possible to encode "data_new" the same way as "data" and save the Encoder for latter use on live incoming data?</p>
  
  <p>Expected hot encoding to be used in th Model for df_new:</p>
  
  <p>Age juli    nick    tom</p>
  
  <p>20  0   0   0</p>
  
  <p>45  1   0   0</p>