I'm trying to find a non-pandas solution to summarising by category.
I have this lookup table as a list of dicts:
lookup_table = [
{"urban_rural": "urban", "technology": "FTTC", "speed": 50},
{"urban_rural": "rural", "technology": "FTTC", "speed": 10},
{"urban_rural": "urban", "technology": "FTTC", "speed": 30}
]
I want to find the mean of 'speed' by category ('urban_rural', and 'technology') so I end up with this:
lookup_table_mean_values = [
{"urban_rural": "urban", "technology": "FTTC", "speed": 40},
{"urban_rural": "rural", "technology": "FTTC", "speed": 10}
]
Edit (add current code):
I didn't want to muddy the water, but as @Patrick Artner has requested, here's where I'm at. Currently this question provides a suggested answer for a dict, providing both simple loop, and Iteritems options, however I've not been able to adapt to the list of dict structure so far.
I would be quite happy using something like this:
lookup_table_mean_values =[float(sum(values)) / len(values) for key, values in lookup_table .iteritems()]