Created
October 8, 2009 21:28
-
-
Save anfedorov/205436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import itemgetter | |
from itertools import groupby | |
get_inning = itemgetter('inning') | |
get_half = itemgetter('half') | |
def group_by_inning(es): | |
return groupby(sorted(es, get_inning), get_inning) | |
def group_by_inning_by_half(es): | |
return [ groupby(sorted(events, get_inning), get_inning) for events in group_by_inning(es) ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment