def groupby(data, field): grouped = Odict() for record in data.values(): if int(record["amount"]) > 1 and ("/" not in args[0] or args[0] == get_field(record, "month")): value = get_field(record, field) current = grouped.get(value, (0, 0)) grouped[value] = (current[0] + int(record["amount"]), current[1] + 1) return grouped
def __init__(self, path, data={}): Pdict.__init__(self, path) Odict.__init__(self, data)