python - Best way to reduce dictionary of lists -


i asking question starting point of pythonic way reduce of list contents in following dictionary using list comprehensions:

{'cycle1': [1, 2407, 2393, 14],  'cycle2': [2, 1657, 1652, 5],   'cycle3': [3, 2698, 2673, 25],   'cycle4': [4, 2116, 2102, 14],   'cycle5': [5, 2065, 2048, 17],   'cycle6': [6, 1633, 1615, 18]} 

each list's columns, though not marked, have these headers:

section_num,account_total,billable_count,nonbillable_count 

i want sum each of last 3 columns, account_total, billable_count, non-billable_count in list comprehension.

i'm not sure how sum going through each list member in comprehension. need ask values of each key, each value being list. i'm little unsure how that.

how using zip? individual sum of each column, although i'm not sure want.

[sum(x) x in zip(*my_dict.values())[1:]] 

this outputs:

[12576, 12483, 93] 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -