title: overwriting column values when using df.at
body: <p>I wrote a function that reads in a csv file, performs some calculations and writes output to the same file. To append the calculated values to a new column, I'm using <code>df.at[index, column_name] = value</code>.</p>
  
  <p>This is my code</p>
  
  <pre><code>def total_calc(n):
       input = pd.read_csv(file_name)
       input['calc'] = 0.0
       for index, row in input.iterrows():
  
         # perform calculations
  
       input.at[index, 'calc'] = calc_value
       input.to_csv(file_name, index=False)
  </code></pre>
  
  <p>When I use the function for multiple values of n, it is writing the values in the same column overwriting the values of previous n values in the dataframe. 
  I tried using i in the function and giving <code>index+i</code>, something like this:</p>
  
  <pre><code>def total_calc(i,n):
       input = pd.read_csv(file_name)
       input['calc'] = 0.0
       for index, row in input.iterrows():
  
         # perform calculations
  
       input.at[index+i, 'calc'] = calc_value
       input.to_csv(file_name, index=False)
  
  total_calc(1,2)
  total_calc(2,8)
  </code></pre>
  
  <p>However, the column values are still overwritten. Is there any way to write the columns for multiple values in the function to the same file without overwriting?</p>
  
  <p>so these are my current dataset columns</p>
  
  <pre><code>names values wickets score
  </code></pre>
  
  <p>I need this after running all required functions</p>
  
  <pre><code>names values wickets score calc calc1 calc2
  </code></pre>