ihgumilar / Hyperscanning2-redesign

Experiment of hyperscanning2-redesign is adding questionnaire inside VR and also improved the UNITY that is used for the experiment.
1 stars 1 forks source link

Notes : Code to count average significant actual score of specific connections out of all pairs (from dictionary), which have key #32

Open ihgumilar opened 2 years ago

ihgumilar commented 2 years ago
# 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}")
ihgumilar commented 2 years ago

Run this code, when all significant actual scores into a list first