title: Find & count identical values in a row in a sorted dict in Python?
body: <p>I sorted a dictionary by one of the keys, which is date/time. I want to count 8 consecutive matching key values ('artist' and 'album') as 1 album play. Is this possible?</p>
  
  <pre><code>from datetime import datetime, timedelta
  from itertools import groupby
  
  def change_date(self):
  
      entries = self.data_to_dict()
      entries.sort(key=lambda x: (x['datetime']), reverse=False)
  
      for x in entries:
          album = x['artist'], x['album']
          grouped_album = [(k, sum(1 for i in g)) for k,g in groupby(album)]
          print grouped_album
  </code></pre>
  
  <p>The above outputs below. I see it's working almost the way I want it to, but can the groupby take 2 keys and deal with them as 1 element? Or should I avoid the groupby all together?</p>
  
  <pre><code>[('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('The War on Drugs', 1), ('Slave Ambient (Deluxe Edition)', 1)]
  [('Arcade Fire', 1), ('Funeral', 1)]
  [('Arcade Fire', 1), ('Reflektor', 1)]
  [('Arcade Fire', 1), ('The Suburbs', 1)]
  [('Tame Impala', 1), ('Lonerism', 1)]
  [('Tame Impala', 1), ('Lonerism', 1)]
  </code></pre>
  
  <p>The raw data is formatted like this:</p>
  
  <pre><code>[{'album': 'Lonerism', 'song': 'Led Zeppelin (Bonus Track)', 'datetime': '2014-12-10 08:03:00', 'artist': 'Tame Impala'}, {'album': 'Lonerism', 'song': 'Feels Like We Only Go Backwards', 'datetime': '2014-12-10 08:00:00', 'artist': 'Tame Impala'}, {'album': 'The Suburbs', 'song': 'Empty Room', 'datetime': '2014-12-10 07:57:00', 'artist': 'Arcade Fire'}]
  </code></pre>