title: Data Manipulation Python -Iterating rows
body: <p>This is my data:</p>
  
  <pre><code>S.No StartMilepost  End Milepost  Segment Length  
  1     0.01           0.03          0.02 
  </code></pre>
  
  <p>I want an ouput like this:</p>
  
  <pre><code>S.No StartMilepost  End Milepost  Segment Length  
  1     0.01           0.02          0.01
  2     0.02           0.03          0.01   
  </code></pre>
  
  <p>I have tried this code: </p>
  
  <pre><code>split_rows = (df2['SegmentLength'] / 0.01)  
  
  while split_rows.any():
      df2.loc[split_rows,'StartMilepost']=df2.loc[split_rows, 'StartMilepost']
  
      #update the end Milepost of old rows
      df2.loc[split_rows, 'EndMilepost'] = df2.loc[split_rows, 'StartMilepost'] 
            +0.01
  
       #update the duration of all rows
      df2['SegmentLength'] = df2['EndMilepost'] - df2['StartMilepost']
  
      #when job is done:
  
  df2.sort_index().reset_index(drop=True)
  df2 = df2.append(new_rows)
  </code></pre>