title: Python Pandas Dataframe: Normalize data between 0.01 and 0.99?
body: <p>I am trying to bound every value in a dataframe between 0.01 and 0.99</p>
  
  <p>I have successfully normalised the data between 0 and 1 using: <code>.apply(lambda x: (x - x.min()) / (x.max() - x.min()))</code> as follows:</p>
  
  <pre><code>df = pd.DataFrame({'one' : ['AAL', 'AAL', 'AAPL', 'AAPL'], 'two' : [1, 1, 5, 5], 'three' : [4,4,2,2]})
  
  df[['two', 'three']].apply(lambda x: (x - x.min()) / (x.max() - x.min()))
  
  df
  </code></pre>
  
  <p>Now I want to bound all values between 0.01 and 0.99</p>
  
  <p>This is what I have tried:</p>
  
  <pre><code>def bound_x(x):
      if x == 1:
          return x - 0.01
      elif x &lt; 0.99:
          return x + 0.01
  
  df[['two', 'three']].apply(bound_x)
  </code></pre>
  
  <p>​
      df</p>
  
  <p>But I receive the following error:</p>
  
  <pre><code>ValueError: ('The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().', u'occurred at index two')
  </code></pre>