title: Sum Cells with Same Date, and Groupby multiple columns
body: <p>I am trying to extract information from a .csv file generated by thingspeak.com. The following is a snapshot of my .csv file titled "feeds.csv"</p>
  
  <p><a href="https://i.imgur.com/WyN6oAn.png" rel="nofollow noreferrer">https://i.imgur.com/WyN6oAn.png</a> </p>
  
  <p>The "field2" column are just values of 1, representing minutes. I want to add all the "field2" values to the same date (which I have done). </p>
  
  <p>I have already successfully been able to parse the date and add the "field2" values related to the date using the groupby function. </p>
  
  <p>The new .csv file generated is shown in the link below. Where Stations is the "field1" values, and "Time (minutes)" is the sum of "field2" values. </p>
  
  <p><a href="https://i.imgur.com/0SzOdtZ.png" rel="nofollow noreferrer">https://i.imgur.com/0SzOdtZ.png</a></p>
  
  <p>However I want the "Station" column to be the Station for a particular date. Right now it is just counting the number of entries under "field1".</p>
  
  <pre><code>import pandas as pd
  df = pd.read_csv("feeds.csv")
  
  df.created_at = df.created_at.str.split(' ').str[0]  
  dfout = df.groupby(['created_at']).count()
  # dfout2 = df.groupby('field1') #Experimenting (ignore for now)
  
  dfout.reset_index(level=0, inplace=True)
  finaldf = dfout[['created_at', 'field1', 'field2']]
  finaldf.columns = ['Date', 'Station', 'On Time (minutes)']
  
  finaldf.to_csv('insertnewname.csv', index=False)
  </code></pre>
  
  <p>The output should be as follows (shown in the link below):</p>
  
  <p><a href="https://i.imgur.com/fNHGaAU.png" rel="nofollow noreferrer">https://i.imgur.com/fNHGaAU.png</a></p>
  
  <p>I know using the .count() simply adds the number of rows (and not sum) of the field2 values. </p>
  
  <p>Any help would be greatly appreciated. </p>
  
  <p>PS. I am a noob at this stuff, so any explanations to help explain the additional code would go a long ways.</p>