title: Pandas Dataframe - record number of rows based on cumulative sum on a column with a condition
body: <p>In below df I already have column &quot;A&quot;. I'm trying to add another column &quot;Desired&quot; where the value is the number of rows below the corresponding A's value, to first satisfy: cumulative sum of A's value &gt;= 8</p>
  <p>For example: row 1 of column &quot;Desired&quot; would be 3 because 5+2+3 &gt;= 8.  rows 2 of column &quot;Desired&quot; would be 4 because 2+3+2+2&gt;=8</p>
  <p>Therefore the ideal new df would be like below.</p>
  <p>df:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>A</th>
  <th>Desired</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>8</td>
  <td>3</td>
  </tr>
  <tr>
  <td>5</td>
  <td>4</td>
  </tr>
  <tr>
  <td>2</td>
  <td>4</td>
  </tr>
  <tr>
  <td>3</td>
  <td>4</td>
  </tr>
  <tr>
  <td>2</td>
  <td>3</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2</td>
  </tr>
  <tr>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>11</td>
  <td>1</td>
  </tr>
  <tr>
  <td>8</td>
  <td>NA</td>
  </tr>
  <tr>
  <td>6</td>
  <td>NA</td>
  </tr>
  </tbody>
  </table>
  </div>