title: Pandas iterating in range. Same number twice?
body: <p>I've written this code and my output is not quite as expected. It seems that the for loop runs through the first iteration twice and then misses out the second and jumps straight to the third. I cannot see where I have gone wrong however so could someone point out the error? Thank you!</p>
  
  <p>Code below:</p>
  
  <pre><code>i = 0
  df_int = df1[(df1.sLap &gt; df_z.Entry[i]) &amp; (df1.sLap &lt; df_z.Exit[i]) &amp; (df1.NLap == Lap1)]
  
  df_Entry = df_int.groupby(df_int.BCornerEntry).aggregate([np.mean, np.std])
  
  
  df_Entry.rename(index={1:  'T'+str(df_z['Turn Number'][i])}, inplace=True)
  
  for i in range(len(df_z)):
      df_int = df1[(df1.sLap &gt; df_z.Entry[i]) &amp; (df1.sLap &lt; df_z.Exit[i]) &amp; (df1.NLap == Lap1)]
  
      df_Entry2 = df_int.groupby(df_int.BCornerEntry).aggregate([np.mean, np.std])
  
      df_Entry2.rename(index={1:  'T'+str(df_z['Turn Number'][i])}, inplace=True)
  
      df_Entry = pd.concat([df_Entry, df_Entry2])
  </code></pre>
  
  <p>df_z is an excel document with data like this:</p>
  
  <pre><code>    Turn Number  Entry  Exit
  0             1    321   441
  1             2    893  1033
  2             3   1071  1184
  3             4   1234  1352
  4             5   2354  2454
  5             6   2464  2554
  6             7   2574  2689
  7             8   2955  3120..... and so on
  </code></pre>
  
  <p>Then df1 is a massive DataFrame with 30 columns and 10's of thousands of rows (hence the mean and std).</p>
  
  <p>My Output should be:</p>
  
  <pre><code>                tLap            
                  mean       std      
  BCornerEntry                                                          
  T1              6.845490  0.591227      
  T2             14.515195  0.541967      
  T3             19.598690  0.319181     
  T4             21.555500  0.246757     
  T5             34.980000  0.518170     
  T6             37.245000  0.209284     
  T7             40.220541  0.322800.... and so on     
  </code></pre>
  
  <p>However I get this:</p>
  
  <pre><code>                tLap            
                  mean       std      
  BCornerEntry                                                          
  T1              6.845490  0.591227      
  T1              6.845490  0.591227      
  T3             19.598690  0.319181     
  T4             21.555500  0.246757     
  T5             34.980000  0.518170     
  T6             37.245000  0.209284     
  T7             40.220541  0.322800..... and so on    
  </code></pre>
  
  <p>T2 is still T1 and the numbers are the same? What have I done wrong? Any help would be greatly appreciated!</p>