Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将术语文档矩阵转换为表格可读表_Python_R_Text Mining_Term Document Matrix - Fatal编程技术网

Python 将术语文档矩阵转换为表格可读表

Python 将术语文档矩阵转换为表格可读表,python,r,text-mining,term-document-matrix,Python,R,Text Mining,Term Document Matrix,我使用R tm软件包创建了一个术语文档矩阵,并通过将其转换为数据帧将其导出为csv 术语文档矩阵的示例部分: 1 10 12 14 15 16 17 century 0 4 0 0 1 5 3 pete 0 2 0 6 1 0 0 additive 2 0 0 0 0 0 0 administration 1 5 3 0 3 0 0 administrati

我使用R tm软件包创建了一个术语文档矩阵,并通过将其转换为数据帧将其导出为csv

术语文档矩阵的示例部分:

        1   10  12  14  15  16  17
century 0   4   0   0   1   5   3
pete    0   2   0   6   1   0   0
additive    2   0   0   0   0   0   0
administration  1   5   3   0   3   0   0
administration  1   0   0   0   0   0   5
administrator   0   0   0   0   0   0   0
aeronautical    3   0   0   45  5   0   0
agency  0   0   5   0   0   0   0
amateur 0   0   6   0   0   0   0
anchor  5   0   1   0   0   6   0
basic   0   0   0   0   0   0   0
charles 0   0   6   0   0   0   0
commercial  0   6   0   0   0   4   0
commercial  0   0   0   0   0   2   0
commission  0   0   3   7   2   0   0
committee   0   4   0   0   1   5   3
compelling  0   2   7   6   1   0   0
construction    2   0   0   0   0   0   0
controlled  1   5   6   0   3   0   0
cooperating 1   0   0   0   0   0   5
cost    0   0   0   0   0   0   0
crewmember  3   0   0   45  0   0   0
depressed   0   0   0   0   0   0   0
developer   0   0   8   0   0   0   0
development 5   0   0   0   0   0   0
development 0   0   0   0   0   0   0
direct  0   0   0   0   0   0   0
如何将其转换为下表中的一个表,该表包含标题和其中的术语,以便在tableau中进行进一步分析

Title   term    freq
1   additive    2
1   administration  1
1   administration  1
1   aeronautical    3
1   anchor  5
1   construction    2
1   controlled  1
1   cooperating 1
1   crewmember  3
1   development 5
10  century 4
10  pete    2
10  administration  5
10  commercial  6
10  committee   4
10  compelling  2
10  controlled  5
12  administration  3
12  agency  5
12  amateur 6
12  anchor  1
12  charles 6
12  commission  3
12  compelling  7
12  controlled  6
12  developer   8
.   ... ..
.   ... ..
.   ... ..
.   ... ..
.   ... ..

这似乎是软件包重塑2中熔体的一种情况,即将数据从“宽”格式重塑为“长”格式。关于这个话题的帖子太多了。对我来说,这看起来像nach熊猫。我不明白你原始数据的格式。你能再解释一下吗?您的数据的标题是什么?@Henrik我将查看重塑线程。谢谢Tengis-这是一个术语文档矩阵,由R text mining tm软件包使用文本文档语料库生成。我不确定它是否会有标题。1、10、12、14等是文件编号。melt成功了!非常感谢亨里克!