You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Python3 code to demonstrate working of
# Convert list of dictionaries to Dictionary Value list
# Using loop
from collections import defaultdict
import numpy as np
# initializing lists
# list_temp = [{"Gfg" : 6},
# {"Gfg" : 8},
# {"Gfg" : 2},
# {"Gfg" : 12},
# {"Gfg" : 22}]
list_temp =[]
a = {"a" : 1}
aa = {"a" : 2}
b = {"b" : 1}
bb = {"b" : 3}
for i in range(4):
list_temp.append(a)
list_temp.append(aa)
list_temp.append(b)
list_temp.append(bb)
# printing original list
print("The original list : " + str(list_temp))
# using loop to get dictionaries
# defaultdict used to make default empty list
# for each key
res = defaultdict(list)
for sub in list_temp:
for key in sub:
res[key].append(sub[key])
# printing result
print("The extracted dictionary : " + str(dict(res)))
average_a = np.mean(res["a"])
print(f"Average score of a {average_a}")
The text was updated successfully, but these errors were encountered:
ihgumilar
changed the title
Notes : Count average significant actual score of specific connections out of all pairs (from dictionary), which have key
Notes : Code to count average significant actual score of specific connections out of all pairs (from dictionary), which have key
Sep 22, 2022
The text was updated successfully, but these errors were encountered: