title: Ambiguous truth value with boolean logic
body: <p>I am trying to use some boolean logic in a function on a dataframe, but get an error:</p>
  
  <p>In [4]:</p>
  
  <pre><code>data={'level':[20,19,20,21,25,29,30,31,30,29,31]}
  frame=DataFrame(data)
  frame
  Out[4]:
  level
  0   20
  1   19
  2   20
  3   21
  4   25
  5   29
  6   30
  7   31
  8   30
  9   29
  10  31
  
  In [35]:
  
  def calculate(x):
      baseline=max(frame['level'],frame['level'].shift(1))#doesnt work
      #baseline=x['level']+4#works
      difftobase=x['level']-baseline
      return baseline, difftobase
  frame['baseline'], frame['difftobase'] = zip(*frame.apply(calculate, axis=1))#works
  </code></pre>
  
  <p>However, this throws the following error at:</p>
  
  <pre><code>baseline=max(frame['level'],frame['level'].shift(1))#doesnt work
  
  
  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 0')
  </code></pre>
  
  <p>I read <a href="https://stackoverflow.com/questions/14386117/how-to-look-back-at-previous-rows-from-within-pandas-dataframe-function-call">How to look back at previous rows from within Pandas dataframe function call?</a> 
  and <a href="http://pandas.pydata.org/pandas-docs/stable/gotchas.html" rel="nofollow noreferrer">http://pandas.pydata.org/pandas-docs/stable/gotchas.html</a>
   but can't figure out how to apply this to my problem?</p>