title: Python (CSV) sum second column(s) if first column value is the same
body: <p>I have a CSV file that looks like this:</p>
  
  <pre><code>25,57
  25,60
  35,60
  35,60
  35,60
  45,70
  45,70
  ...
  </code></pre>
  
  <p>What I need is to create a NEW csv file from this one that keeps only one entry for the first column and sums all the values of the second column where the first column's value is the same.</p>
  
  <p>Example of what I need to make from the above:</p>
  
  <pre><code>25, 117
  35, 180
  45, 140
  </code></pre>
  
  <p>NOTE: I tried pandas grouby and an error came up in my library...</p>
  
  <p><strong>Tried Code:</strong></p>
  
  <p>IdandScoreArray = np.empty((27,2), dtype = int)
  with f as csvfile:</p>
  
  <pre><code>csvreader = csv.DictReader(csvfile)
  
  for row in csvreader:
  
          IdScore = (row['user_id'], row['grade_id'])
  
          IdandScoreArray = np.append(IdandScoreArray, [IdScore], axis = 0)
  </code></pre>
  
  <p>df = pd.DataFrame(IdandScoreArray, columns = ['First', 'Second'])</p>
  
  <p>df.groupbby('First').sum</p>
  
  <p>print df</p>
  
  <p>(something like that)</p>