I have a nested dictionary that looks like this(this is pretty shortened version):
my_dict = {('rs1', rn1): {u'rs2': u'rs3', u'rs4': u'rs5', u'rs6': u'rs7', u'rs8': u'rs9', u'rs10t': u'rs11', u'rs12': u'rs13', u'rs14': u'rs15', u'rs16': u'rs17', u'rs18': u'rs19'}, ('rs21', rn2): {u'rs22': u'rs23'}, ('rs24', rn2): {u'rs25': u'rs26', u'rs27': u'rs28', u'rs29': u'rs30'}
And I would like to have an excel that looks like
Im trying with:
new_list = []
for k1 in remove_empties_from_dict(combined_dict):
curr_dict = remove_empties_from_dict(combined_dict)[k1]
for k2 in curr_dict:
new_dict = {'col1': k1, 'col2': k2}
for k3 in curr_dict[k2]:
new_dict = {'col1': k1, 'col2': k2, 'col3': k3}
for k4 in curr_dict[k2][k3]:
new_dict= {'col1': k1, 'col2': k2, 'col3': k3, 'col4': k4}
new_list.append(new_dict)
df = pd.DataFrame(new_list)
print df
It says an error:
"for k4 in curr_dict[k2][k3]: TypeError: 'float' object is not iterable" Any idea how to change inner values to strings, apparently they are floats.
Thank you!