title: python iteration over each bins in a dataframe
body: <p>I'm working on a measurement dataset. I have data in a dataframe like in the below table, the data is power and windspeed for every 0.5m/s windspeed bin. But I need to calculate the Sensitivity column at each bin from power and windspeed values.  The formula for sensitivity is </p>
  
  <pre><code>sensitivity = abs ( (Pi - Pi_1) / (Vi - Vi_1) )
  </code></pre>
  
  <p>We have to subtract the current bin values of power and speed from previous bin value. </p>
  
  <p>I need a <code>for loop</code>  script for this scenario. I'm really a bit confused by using all <code>for loop</code> options, can someone help me on this please?  </p>
  
  <p>Note: I got these values from the below <code>DataFrame</code> script:</p>
  
  <pre><code>uncut = df.groupby(pd.cut(df.normalized_speed, ws_bin))['pt_power_avg', 'normalized_speed'].mean() 
  </code></pre>
  
  <p>Data Table:</p>
  
  <pre><code>normalized_speed    pt_power_avg [Pi] normalized_speed [Vi]  *sensitivity*
  [Ci]"
  (0, 0.5]                 0                        0                   -   
  (0.5, 1]                 0                        0                   -   
  (1, 1.5]                 0                        0                   -   
  (1.5, 2]                 0                        0                   -   
  (2, 2.5]                 6.46                     2.44               2.6 
  (2.5, 3]                14.22                     2.73              26.2 
  (3, 3.5]                27.05                     3.26              24.4 
  (3.5, 4]                56.67                     3.77              58.6 
  (4, 4.5]                88.55                     4.26              64.7 
  (4.5, 5]               121.95                     4.76              66.8 
  (5, 5.5]               166.87                     5.26              89.5 
  (5.5, 6]               221.16                     5.74             112.6 
  (6, 6.5]               283.94                     6.26             122.4 
  (6.5, 7]               310.32                     6.74              54.7 
  (7, 7.5]               472.59                     7.29             297.0 
  (7.5, 8]               582.02                     7.70             261.2 
  (8, 8.5]               703.98                     8.17             261.1 
  (8.5, 9]               927.60                     8.77             375.4 
  (9, 9.5]               995.10                     9.11             194.1    
  </code></pre>