title: Python + Pandas: Add value to specific row in csv-file
body: <p>I have a csvfile which looks like this</p>
  
  <pre><code>Date,A,B,C,...,X
  2016/04,ColA,ColB,ColC,...,ColX
  2016/05,ColA,ColB,ColC,...,ColX
  2016/06,ColA,ColB,ColC,...,ColX
  2016/07,ColA,ColB,ColC,...,ColX
  2016/08,ColA,ColB,ColC,...,ColX
  2016/09,ColA,ColB,ColC,...,ColX
  2016/10,ColA,ColB,ColC,...,ColX
  2016/11,ColA,ColB,ColC,...,ColX
  2016/12,ColA,ColB,ColC,...,ColX
  </code></pre>
  
  <p>and a function which creates lists like this:</p>
  
  <pre><code>['2016/08', 67287800000.00001, '2016/09', -22714300000.0, '2016/10', 97335100000.0, '2016/11', 97579300000.0, '2016/12', 97723900000.0]
  </code></pre>
  
  <p>These lists get passed to following function</p>
  
  <pre><code>def write_graph_data(cat, data_list, column):
      if len(data_list) &gt; 0:
          row_num = 0
  
          for row in pd.read_csv('./data/%s_f.csv' % cat, sep=',', error_bad_lines=False, chunksize=1, header=0):
              date = row.at[row_num,'Date']
  
              if date == data_list[0]:
                  row[column] = data_list[1]
                  data_list.pop(0)
                  data_list.pop(0)
  
              row_num += 1
  </code></pre>
  
  <p>This function reads the csv file row-wise and for every row checks the value in the 'Date' column. If the value is the same as the first list entry, the second list entry will be added to the row in a new column like this</p>
  
  <pre><code>2016/08,ColA,ColB,ColC,...,ColX,67287800000.00001
  </code></pre>
  
  <p>How can i save my csvfile with the changed row(s)?</p>