Compute element-wise means across several identical dictionaries of lists

Viewed 17

I am trying to come up with an elegant way to achieve the following:

Start with a list of dictionaries:

dict_list = [
{0: [1, 2], 1: [3, 4]}
{0: [5, 6], 1: [7, 8]}
]

The keys are identical across each dictionary in the list. Each key in each dictionary has an array of values.

I want to get a single "summary" dictionary which contains the same keys, and the element-by-element means of the arrays:

means = 
{0: [3, 4], 1: [5, 6]}

Any help is much appreciated!

0 Answers
Related