dict_df = counts.stack().join(h.stack().rename('condition')).unstack()
for pos, row in dict_df.iterrows():
    d['M']['H0'].append((row.loc['condition', 'H0'], row.loc['M', 'H0']))
d['S']['H0'].append((row.loc['condition', 'H0'], row.loc['S', 'H0']))
d['M']['H1'].append((row.loc['condition', 'H1'], row.loc['M', 'H1']))
d['S']['H1'].append((row.loc['condition', 'H1'], row.loc['S', 'H1']))
dict(d)
{'M': defaultdict(list, {'H0': [('AgA', 4), ('TgA', 3), ('CgT', 2), ('GgC',
    1)], 'H1': [('CgC', 1), ('AgC', 0), ('GgA', 0), ('TgG', 1)]}), 'S':
    defaultdict(list, {'H0': [('AgA', 2), ('TgA', 1), ('CgT', 0), ('GgC', 0
    )], 'H1': [('CgC', 2), ('AgC', 2), ('GgA', 2), ('TgG', 3)]})}
How to read two lines from a file and create dynamics keys in a for-loop using python?