title: Pandas conditional statement returning only zeros
body: <p>I am working with a DataFrame showing financial data. I created a class to easily test multiple variations of a strategy. I created a new column called &quot;postion&quot; that tests a conditional statement. At first I got the error &quot; The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().&quot; but managed to solve that by iterating over each item.</p>
  <p>But now all values of the &quot;position&quot; column are equal to zero, which does not make sense to me because there are multiple occurences in the dataframe where I can see that the condition is True. Here is the code:</p>
  <pre><code>        for bar in range(len(self.data)):
             if self.data['close'].iloc[bar] &gt; self.data['max_high'].iloc[bar]:
               self.data['position'] = 1
             elif self.data['close'].iloc[bar] &lt; self.data['max_low'].iloc[bar]:
               self.data['position'] = -1
             else:
               self.data['position'] = 0
  </code></pre>
  <p>Here is the output(attached image below):</p>
  <p><a href="https://i.stack.imgur.com/rqHSW.png" rel="nofollow noreferrer">DataFrame</a></p>
  <p>Thanks for any help in advance</p>