title: Encountering ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
body: <p>I have a function</p>
  <pre><code>def cruise_fun(speed, accl, acmx, dcmx):
      count = 0
      index = []
      for i in range(len(speed.dropna())):
          if ((speed[i]&gt;40) &amp; (accl[i]&lt;acmx*0.2) &amp; (accl[i]&gt;dcmx*0.2)):
              count +=1
              index.append(i)
                      
      return count, index
  </code></pre>
  <p>This function is being called in the following statement</p>
  <pre><code>cruise_t_all, index_all =cruise_fun(all_data_speed[0], acc_val_all[0], acc_max_all, decc_max_all)
  </code></pre>
  <p><code>all_data_speed</code> and <code>acc_val_all</code> are two dataframes of 1 column and 38287 rows. <code>acc_max_all</code> and <code>decc_max_all</code> are two float64 values. I have tried to implement solutions provided in stackoverflow as much as I could. I have used both <code>and</code> and <code>&amp;</code>. I can not get around the problem.</p>