I am trying to split a dictionary of lists into a list of dictionaries.
I have tried following the examples here and here_2. Here_2 is for python 2.x and does not seem to work on python 3.x
The first linked example, here, almost works except I only get the first dictionary key value pair back as 1 list.
using zip() to convert dictionary of list to list of dictionaries
test_dict = { "Rash" : [1], "Manjeet" : [1], "Akash" : [3, 4] }
res = [dict(zip(test_dict, i)) for i in zip(*test_dict.values())]
print ("The converted list of dictionaries " + str(res))
Out: The converted list of dictionaries [{‘Rash’: 1, ‘Akash’: 3, ‘Manjeet’: 1}]
DESIRED Out: The converted list of dictionaries [{‘Rash’: 1, ‘Akash’: 3, ‘Manjeet’: 1}, {‘Akash’: 4}]