title: Convert categorical data into numerical data in Python
body: <p>I have a data set. One of its columns - "Keyword" - contains categorical data. The machine learning algorithm that I am trying to use takes only numeric data. I want to convert "Keyword" column into numeric values - How can I do that? Using NLP? Bag of words?</p>
  
  <p>I tried the following but I got <code>ValueError: Expected 2D array, got 1D array instead</code>.</p>
  
  <pre><code>from sklearn.feature_extraction.text import CountVectorizer
  count_vector = CountVectorizer()
  dataset['Keyword'] = count_vector.fit_transform(dataset['Keyword'])
  from sklearn.model_selection import train_test_split
  y=dataset['C']
  x=dataset(['Keyword','A','B'])
  x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=0)
  from sklearn.linear_model import LinearRegression
  regressor=LinearRegression()
  regressor.fit(x_train,y_train)
  </code></pre>