title: TypeError: argument must be a string or number on column with strings that are numbers
body: <p>I have a dataset with categories. In column 4 I have 2 values( two and four which are strings). Do you know why I get the error and how to fix it?TypeError: argument must be a string or number</p>
  <pre><code>Traceback (most recent call last):
  
    File &quot;C:..&quot;.py&quot;, line 112, in _encode
      res = _encode_python(values, uniques, encode)
  
    File &quot;C:...py&quot;, line 60, in _encode_python
      uniques = sorted(set(values))
  
  TypeError: '&lt;' not supported between instances of 'str' and 'float'
  </code></pre>
  <p>During handling of the above exception, another exception occurred:</p>
  <pre><code>Traceback (most recent call last):
  
    File &quot;C...&quot;.py&quot;, line 35, in &lt;module&gt;
      X[:, 4] = labelencoder_X4.fit_transform(X[:, 4])
  
    File &quot;C:...py&quot;, line 252, in fit_transform
      self.classes_, y = _encode(y, encode=True)
  
    File &quot;C:....py&quot;, line 114, in _encode
      raise TypeError(&quot;argument must be a string or number&quot;)
  
  TypeError: argument must be a string or number
  </code></pre>
  <p>Code:</p>
  <pre><code>import numpy as np #mathematical tools
  import matplotlib.pyplot as plt #plot nice charts
  import pandas as pd #import and manage data sets
  
  # Making a list of missing value types
  missing_values = [&quot;?&quot;]
  df= pd.read_csv('D:\\data.csv',na_values = missing_values)
  
  #print the new table with the missing values 
  # print (df)
  # print (df.isnull())
  
  
  X = df.iloc[:, :-1].values #Matrix - independent variables (features)
  y = df.iloc[:, 24].values #dependent variables vectors
  
  
  from sklearn.preprocessing import LabelEncoder, OneHotEncoder
  labelencoder_X2 = LabelEncoder()
  X[:, 2] = labelencoder_X2.fit_transform(X[:, 2]) #gas=0, fuel=1 
  
  labelencoder_X3 = LabelEncoder()
  X[:, 3] = labelencoder_X3.fit_transform(X[:, 3])
  
  #I get an error her
  labelencoder_X4 = LabelEncoder()
  X[:, 4] = labelencoder_X4.fit_transform(X[:, 4])
  
  labelencoder_X5 = LabelEncoder()
  X[:, 5] = labelencoder_X5.fit_transform(X[:,5])
  
  labelencoder_X6 = LabelEncoder()
  X[:, 6] = labelencoder_X6.fit_transform(X[:, 6])
  
  labelencoder_X7 = LabelEncoder()
  X[:, 7] = labelencoder_X7.fit_transform(X[:, 7])
  
  labelencoder_X13 = LabelEncoder()
  X[:, 13] = labelencoder_X13.fit_transform(X[:, 13])
  
  labelencoder_X14 = LabelEncoder()
  X[:, 14] = labelencoder_X14.fit_transform(X[:, 14])
  
  labelencoder_X15 = LabelEncoder()
  X[:, 16] = labelencoder_X14.fit_transform(X[:, 16])
  
  from sklearn.impute import SimpleImputer
  imputer=SimpleImputer(missing_values=&quot;NaN&quot;, strategy='mean')
  imputer.fit(X[:, 1:24])  
  X[:, 1:24]=imputer.transform(X[:, 1:24])
  </code></pre>
  <p>Thank you for the help!</p>
  <p><img src="https://i.stack.imgur.com/46Fp1.png" alt="img of the column" /></p>