How to average list of dicts?

Consider a list of dicts

a = {(0,1) : 10, (2,9): 20}
b = {(0,1) : 20, (2,9): 60, (3,3): 15}
list_of_dicts = [a,b]

How can I obtain an average c from this such that

c = {(0,1) : 15, (2,9): 40, (3,3):15}

A related question is Get average value from list of dictionary, but the solution doesn't account for key (3,3).



Read more here: https://stackoverflow.com/questions/66282047/how-to-average-list-of-dicts

Content Attribution

This content was originally published by AngusTheMan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: