title: "ValueError: could not convert string to float" error in scikit-learn
body: <p>I'm running the following script:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import pandas as pd
  from sklearn.preprocessing import OneHotEncoder
  dataset = pd.read_csv('data/50_Startups.csv')
  X = dataset.iloc[:, :-1].values
  y = dataset.iloc[:, 4].values
  onehotencoder = OneHotEncoder(categorical_features=3, 
  handle_unknown='ignore')
  onehotencoder.fit(X)
  </code></pre>
  
  <p>The data head looks like:
  <a href="https://i.stack.imgur.com/mEkVF.png" rel="noreferrer">data</a></p>
  
  <p>And I've got this: </p>
  
  <blockquote>
    <p>ValueError: could not convert string to float: 'New York'</p>
  </blockquote>
  
  <p>I read the answers to <a href="https://stackoverflow.com/questions/8420143/valueerror-could-not-convert-string-to-float-id">similar</a> questions and then opened scikit-learn  <a href="https://scikit-learn.org/stable/modules/preprocessing.html#encoding-categorical-features" rel="noreferrer">documentations</a>, but how you can see scikit-learn authors doesn't have issues with spaces in strings</p>
  
  <p>I know that I can use <code>LabelEncocder</code> from <code>sklearn.preprocessing</code> and then use OHE and it works well, but in that case </p>
  
  <pre><code>In case you used a LabelEncoder before this OneHotEncoder to convert the categories to integers, then you can now use the OneHotEncoder directly.
  warnings.warn(msg, FutureWarning)
  </code></pre>
  
  <p>massage occurs.</p>
  
  <p>You can use <a href="https://pastebin.com/RtwkfsHJ" rel="noreferrer">full csv file</a> or</p>
  
  <pre><code>[[165349.2, 136897.8, 471784.1, 'New York', 192261.83],
  [162597.7, 151377.59, 443898.53, 'California', 191792.06],
  [153441.51, 101145.55, 407934.54, 'Florida', 191050.39],
  [144372.41, 118671.85, 383199.62, 'New York', 182901.99],
  [142107.34, 91391.77, 366168.42, 'Florida', 166187.94]]
  </code></pre>
  
  <p>5 first lines to test this code.</p>