title: KeyError: '[ ...... ] not in index'
body: <p>I am doing standardization of my dataset</p>
  
  <pre><code>def standardization(new_df2, labelcol):
      from sklearn.preprocessing import StandardScaler
      labels = new_df2[labelcol]
      del new_df2[labelcol]
      scaled_features = StandardScaler().fit_transform(new_df2.values)
      new_df3 = pd.DataFrame(scaled_features, index = new_df2, columns = 
         new_df2.columns)
      new_df3[labelcol] = labels
  
      return new_df3
  
      labelcol = new_df2.population     #population is one of the columns in dataframe
      new_df3 = standardization(new_df2, labelcol)
      print(new_df3)
  </code></pre>
  
  <p>I receive the following error!</p>
  
  <pre><code>KeyError: '[  322.  2401.   496. ...,  1007.   741.  1387.] not in index'
  </code></pre>
  
  <p>As far I've seen, <code>322, 2401, ...</code> are the values in the <code>population</code>  column.</p>
  
  <p>Please help me how to get rid of this error. What is this implying?</p>
  
  <p>P.S: <code>new_df2</code> = <code>(20640, 14)</code> and <code>labelcol.shape</code> = <code>(20640,)</code></p>