title: Add values to a data frame column at a specific row number
body: <p>I have a data frame <code>df</code> call which looks like:</p>
  <pre><code>                  A          B             C
  Date            
  02/02/2007  14.8966   0.289371   0.009984836
  05/02/2007  14.8719   0.288368  -0.001659473
  06/02/2007  14.9295   0.279869   0.003865595
  07/02/2007  15.0035   0.283038   0.004944386
  08/02/2007  15.0528   0.277092   0.003280513
  09/02/2007  14.7733   0.28663   -0.018742523
  12/02/2007  14.6911   0.286458  -0.005579629
  13/02/2007  14.996    0.275362   0.020541631
  14/02/2007  15.5731   0.253263   0.037761568
  </code></pre>
  <p>I have a for loop in which I am using to manipulate a timeseries.  The result is a variable called <code>testValue</code> that I would like to add to <code>df</code> in a new column called <code>'D'</code> at the row reference <code>endpoint</code> (endpoint is a sequentially increasing integer).</p>
  <pre><code>for i in range(buildRange,len(pair_data)-calcRange+1):
      startpoint=i
      endpoint = startpoint+calcRange
      Calc_df=df[startpoint:endpoint].copy()
      Calc_df['C']=Calc_df.iloc[-1, Calc_df.columns.get_loc('A')]-Calc_df['B']
      testValue= sum(x for x in Calc_df[&quot;C&quot;] if x &gt; 0)
      
      df.loc[endpoint, 'D'] = testValue
      
  </code></pre>
  <p>So over the course of the loop column 'D' will build up with testValue values.  Is it possible to reference a row in a dataframe and not the index? At the moment using <code>df.loc[endpoint, 'D'] = testValue</code>  creates a new column <code>'D'</code> but adds the data to the bottom of the data-frame and not to the correct row. (I think it's because endpoint is an integer and the index is date so it can't find the reference so creates a new one at the bottom of the data frame).</p>
  <p>So for example if endpoint started at 4 the desired output to look like:</p>
  <pre><code>              A          B             C             D
  Date            
  02/02/2007  14.8966   0.289371   0.009984836
  05/02/2007  14.8719   0.288368  -0.001659473
  06/02/2007  14.9295   0.279869   0.003865595
  07/02/2007  15.0035   0.283038   0.004944386    1.36535
  08/02/2007  15.0528   0.277092   0.003280513    0.27821
  09/02/2007  14.7733   0.28663   -0.018742523    0.25356
  12/02/2007  14.6911   0.286458  -0.005579629    2780435
  13/02/2007  14.996    0.275362   0.020541631    0.36635
  14/02/2007  15.5731   0.253263   0.037761568    0.25368
          :                            :
  31/12/2007  15.9364   0.763263   0.047435768    0.24663
  </code></pre>
  <p>(Values in column 4 are just for illustrative purposes and would note correct if the code was run).</p>