title: Add the elements in a list up on a condition in the corresponding list in Python
body: <p>I have three lists </p>
  
  <pre><code>vr=[5, 10, 15, 20, 25]
  vr_bin = [1,2,3,4,5,6,7,8,9,10]
  crf= [0.0357, 0.7124, 0.1707, 0.0142, 0.0328, 0.0291, 0.0244, 0.0206, 0.0334, 1.7124]
  </code></pre>
  
  <p>where <em>vr_bin</em> and <em>crf</em> are of same length. I have to take first value of <em>vr</em> (for example 5) and compare it with <em>vr_bin</em> (for which value of <code>i</code>, <code>vr_bin[i] &lt;= vr[0]</code>) then sum <em>crf</em> up to  <code>crf[i]</code>.</p>
  
  <p>In our example, up to <code>vr_bin[4]</code> will satisfy our condition (since <code>vr_bin[4]</code> is <code>5</code> and <code>vr[0]</code> is <code>5</code>). So I want to calculate  <code>crf[0]+crf[1]+crf[2]+crf[3]+crf[4]</code>. I tried with the following code </p>
  
  <pre><code>total_crf = crf[vr_bin &lt;= vr].sum()
  </code></pre>
  
  <p>But I am getting the following error <code>AttributeError: 'float' object has no attribute 'sum'</code> Please suggest a method for solving this. Thankyou</p>