title: pandas DataFrame column manipulation using previous row value
body: <p>I have below pandas DataFrame</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>color</th>
  <th>direction</th>
  <th>Total</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>-1.0</td>
  <td>1.0</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>0</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>0</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>0</td>
  </tr>
  <tr>
  <td>-1.0</td>
  <td>1.0</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>-1.0</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>0</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I am trying to update the total column based on below logic.</p>
  <p>if df['color'] == 1.0 and df['direction'] == 1.0 then Total should be Total of previous row + 1. if Total of previous row is NaN, then 0+1</p>
  <p>Note: I was trying to read the previous row total using df['Total'].shift() + 1 but it didnt work.</p>
  <p><strong>Expected DataFrame.</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>color</th>
  <th>direction</th>
  <th>Total</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>-1.0</td>
  <td>1.0</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>1</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>2</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>3</td>
  </tr>
  <tr>
  <td>-1.0</td>
  <td>1.0</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>-1.0</td>
  <td>NaN</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>1</td>
  </tr>
  <tr>
  <td>1.0</td>
  <td>1.0</td>
  <td>2</td>
  </tr>
  </tbody>
  </table>
  </div>