title: Python Dataframe: normalize a numerical column using lambda
body: <p>I tried to use the following code to normalize a column in python data frame:</p>
  
  <pre><code>df['x_norm'] = df.apply(lambda x: (x['X'] - x['X'].mean()) / (x['X'].max() - x['X'].min()),axis=1)
  </code></pre>
  
  <p>but got the following error:</p>
  
  <pre><code>    df['x_norm'] = df.apply(lambda x: (x['X'] - x['X'].mean()) / (x['X'].max() - x['X'].min()),axis=1)
  AttributeError: ("'float' object has no attribute 'mean'", u'occurred at index 0')
  </code></pre>
  
  <p>Does anyone know what I missed here? Thanks!</p>