title: How to use OneHotEncoder for multiple columns and automatically drop first dummy variable for each column?
body: <p>This is the dataset with 3 cols and 3 rows</p>
  
  <blockquote>
    <p><strong>Name    Organization    Department</strong></p>
    
    <p>Manie     ABC2    FINANCE</p>
    
    <p>Joyce     ABC1    HR</p>
    
    <p>Ami   NSV2    HR</p>
  </blockquote>
  
  <p>This is the code I have:</p>
  
  <p>Now it is fine till here, how do i drop the first dummy variable column for each ?</p>
  
  <pre><code># Importing the libraries
  import numpy as np
  import matplotlib.pyplot as plt
  import pandas as pd
  
  # Importing the dataset
  dataset = pd.read_csv('Data1.csv',encoding = "cp1252")
  X = dataset.values
  
  
  # Encoding categorical data
  from sklearn.preprocessing import LabelEncoder, OneHotEncoder
  labelencoder_X_0 = LabelEncoder()
  X[:, 0] = labelencoder_X_0.fit_transform(X[:, 0])
  labelencoder_X_1 = LabelEncoder()
  X[:, 1] = labelencoder_X_1.fit_transform(X[:, 1])
  labelencoder_X_2 = LabelEncoder()
  X[:, 2] = labelencoder_X_2.fit_transform(X[:, 2])
  
  onehotencoder = OneHotEncoder(categorical_features = "all")
  X = onehotencoder.fit_transform(X).toarray()
  </code></pre>