[英]Convert Dictionary to Pandas DataFrame
I have a Python dictionary of dictionaries that models the TF-IDF weights of words in a set of documents. 我有一本字典的Python字典,该字典对一组文档中单词的TF-IDF权重进行建模。 Like that: 像那样:
Corpus_dict = {"Doc1.txt": {'word1': XXXX , 'word2': XXXX , ... , wordn: xxx } "Doc2.txt": {'word1': XXXX , 'word2': XXXX , ... , wordn: xxx } Corpus_dict = {“ Doc1.txt”:{'word1':XXXX,'word2':XXXX,...,wordn:xxx}“ Doc2.txt”:{'word1':XXXX,'word2':XXXX,。 ..,wordn:xxx}
... "Docm.txt": {'word1': XXXX , 'word2': XXXX , ... , wordn: xxx }} ...“ Docm.txt”:{'word1':XXXX,'word2':XXXX,...,wordn:xxx}}
Where xxx is the TF-IDF value for each of n words. 其中xxx是n个字中每个字的TF-IDF值。 I'd like to convert it to the folowing Pandas Data Frame: 我想将其转换为以下Pandas数据框:
keys Doc1 Doc2 ... Docn
word1 xxx xxx xxx
word2 xxx xxx xxx
...
word nxxx xxx xxx
Can someone give me some help? 有人可以给我些帮助吗?
Sorry for bad english and thanks! 对不起,英语不好,谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.