title: Treating data as categorical in linear regression
body: <p>I have data in a <code>csv</code> file that looks somewhat like this:</p>
  
  <pre><code>column1    column2
     b          2
     c          4
     z          1
     g          3
  ...
  </code></pre>
  
  <p>(This is not the real data) <code>Column1</code> is categorical and <code>column2</code> is continuous and I want to carry out linear regression on this data. My code looks like this at the moment:</p>
  
  <pre><code># Function to get data from the csv file.
  def import_data(file_name):
   df = pd.read_csv(file_name).drop_duplicates()
   X_parameter = []
   Y_parameter = []
   for alpha, beta in zip(df['column1'], df['column2']):
         X_parameter.append([float(alpha)])
         Y_parameter.append(float(beta))
   return X_parameter, Y_parameter
  
  
  X, Y = import_data(filename)
  def linear_model_main(X_parameters, Y_parameters, predict_value):
  
   # Create linear regression object
  
   regress = linear_model.LinearRegression()
   regress.fit(X_parameters, Y_parameters)
   prediction_outcome = regress.predict(predict_value)
   predictions = {}
   predictions['intercept'] = regress.intercept_
   predictions['coefficient'] = regress.coef_
   predictions['predicted_value'] = prediction_outcome
   return predictions
  </code></pre>
  
  <p>I'm not sure how to specify in this code that <code>column1</code> is categorical? I tried changing it to numerical data (<code>a = 1, b = 2, ...</code>) but Python is treating it as continuous.</p>