I have a dictionary of dictionaries in python like the following example:
example:
result = {
1: {'A': 11472, 'C': 8405, 'T': 11428, 'G': 6613},
2: {'A': 11678, 'C': 9388, 'T': 10262, 'G': 6590},
3: {'A': 2945, 'C': 25843, 'T': 6980, 'G': 2150},
4: {'A': 1149, 'C': 24552, 'T': 7000, 'G': 5217},
5: {'A': 27373, 'C': 3166, 'T': 4494, 'G': 2885},
6: {'A': 19300, 'C': 4252, 'T': 7510, 'G': 6856},
7: {'A': 17744, 'C': 5390, 'T': 7472, 'G': 7312}
}
and I want to make a numpy array in python using the values of inner dictionaries. in fact in the example there are 7 inner dictionaries with 4 items so, in the array thet would be 7 lists with 4 items. so, every item in the in the numpy array is one of the values in the inner dictionaries.
for instance this is the 1st inner dictionary:
{'A': 11472, 'C': 8405, 'T': 11428, 'G': 6613}
and this would be the 1st list in the numpy array:
[ 11472, 8405, 11428, 6613]
I am trying to do that in python using the following line but it does not return expected output.
import pandas as pd
df = pandas.DataFrame(result, index=[0])
do you know how to fix it?
here is the expected output:
array([[ 11472, 8405, 11428, 6613],
[ 11678, 9388, 10262 , 6590],
[ 2945, 25843, 6980 , 2150],
[ 1149, 24552, 7000 , 5217],
[ 27373, 3166, 4494 , 2885],
[ 19300, 4252, 7510, 6856],
[ 17744, 5390, 7472, 7312]])