title: OneHotEncoding : TypeError: cannot perform reduce with flexible type
body: <p>I was trying to fit OneHotEncoder on the X_train and then transform on X_train, X_test
  However this resulted in error:</p>
  <pre><code># One hot encoding 
  from sklearn.preprocessing import OneHotEncoder
  encode_columns = ['borough','building_class_category', 'commercial_units','residential_units']
  
  enc = OneHotEncoder(handle_unknown='ignore')
  enc.fit(X_train[encode_columns])
  X_train = enc.transform(X_train[encode_columns])
  X_test = enc.transform(X_test[encode_columns])
  X_train.head()
  </code></pre>
  <p>Error:</p>
  <pre><code>      4 
        5 enc = OneHotEncoder(handle_unknown='ignore')
  ----&gt; 6 enc.fit(X_train[encode_columns])
        7 X_train = enc.transform(X_train[encode_columns])
        8 X_test = enc.transform(X_test[encode_columns])
  
  TypeError: cannot perform reduce with flexible type
  </code></pre>
  <p>Sample row of X_train:</p>
  <p><a href="https://i.stack.imgur.com/rCesl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rCesl.png" alt="enter image description here" /></a></p>