title: How to apply LabelEncoder for a specific column in Pandas dataframe
body: <p>I have a dataset loaded by dataframe where the class label needs to be encoded using <code>LabelEncoder</code> from scikit-learn. The column <code>label</code> is the class label column which has the following classes:</p>
  
  <pre><code>[‘Standing’, ‘Walking’, ‘Running’, ‘null’]
  </code></pre>
  
  <p>To perform label encoding, I tried the following but it does not work. How can I fix it? </p>
  
  <pre><code>from sklearn import preprocessing
  import pandas as pd
  
  df = pd.read_csv('dataset.csv', sep=',') 
  df.apply(preprocessing.LabelEncoder().fit_transform(df['label']))
  </code></pre>