Data frame:
pair = collections.defaultdict(collections.Counter)
e.g.
pair = {\'doc1\': {\'word1\':4, \'word2\':3},
The Counter is also a dict. But depend on you need, maybe the follow code is you want.
Counter
dict
new_pair ={} for doc, tab in pari.items(): new_pair[doc] = {} for word, freq in tab.items(): new_pair[doc][word] = freq
the new_pair dict is you want. Good Luck!
new_pair