title: How to loop over a dataframe, add new fields to a series, then append that series to a csv?
body: <p>Given a Pandas dataframe such as:</p>
  
  <pre><code>Name   Age
  John   20
  Mary   65
  Bob    55
  </code></pre>
  
  <p>I wish to iterate over the rows, decide whether each person is a senior (age>=60) or not, create a new entry with an extra column, then append that to a csv file such that it (the csv file) reads as follows:</p>
  
  <pre><code>Name   Age  Senior
  John   20   False
  Mary   65   True
  Bob    55   False
  </code></pre>
  
  <p>Other than saving the data to a csv, I am able to do the rest by turning the series the loop is currently iterating over to a dictionary then adding a new key.</p>
  
  <pre><code>for idx, e in records.iterrows():
  
          entry = e.to_dict()
          entry["senior"] = (entry["age"]&lt;60)
  
  </code></pre>
  
  <p>Simply converting dict to series to dataframe isnt writing it to the csv file properly. Is there a pandas or non-pandas way of making this work?</p>
  
  <p><strong>IMPORTANT EDIT :</strong> The above is a simplified example, I am dealing with hundreds of rows and the data I want to add is a long string <strong>that will be created during run time</strong>, so looping is mandatory. Also, adding that to the original dataframe isnt an option as I am pretty sure Ill run out of program memory at some point (so I cant add the data to the original dataframe nor create a new dataframe with all the information). <strong>I dont want to add the data to the original dataframe, only to a copy of a "row" that will then be appended to a csv.</strong></p>
  
  <p>The example is given to provide some context for my question, but the main focus should be on the question, not the example.</p>