title: Memory error when using fit_transform with OneHotEncoder
body: <p>I am trying to One Hot Encode categorical columns in my dataset. I am using the following function:</p>
  
  <pre><code>def create_ohe(df, col):
      le = LabelEncoder()
      a = le.fit_transform(df_new[col]).reshape(-1,1)
      ohe = OneHotEncoder(sparse=False)
      column_names = [col + "_" + str(i) for i in le.classes_]
      return (pd.DataFrame(ohe.fit_transform(a), columns=column_names))
  </code></pre>
  
  <p>I am getting MemoryError when I call the function in this loop:</p>
  
  <pre><code>for column in categorical_columns:
      temp_df = create_ohe(df_new, column)
      temp = pd.concat([temp, temp_df], axis=1)
  </code></pre>
  
  <p>Error Traceback:</p>
  
  <pre><code>MemoryError                               Traceback (most recent call last)
  &lt;ipython-input-40-9b241e8bf9e6&gt; in &lt;module&gt;
        1 for column in categorical_columns:
  ----&gt; 2     temp_df = create_ohe(df_new, column)
        3     temp = pd.concat([temp, temp_df], axis=1)
        4 print("\nShape of final df after one hot encoding: ", temp.shape)
  
  &lt;ipython-input-34-1530423fdf06&gt; in create_ohe(df, col)
        8     ohe = OneHotEncoder(sparse=False)
        9     column_names = [col + "_" + str(i) for i in le.classes_]
  ---&gt; 10     return (pd.DataFrame(ohe.fit_transform(a), columns=column_names))
  
  MemoryError: 
  </code></pre>