首页 > 解决方案 > 将相同的标签循环到多文档

问题描述

我有一个带有给定数据框的文本文档语料库:

       Category    Document
 0        a           1
 1      None          2
 2      None          3
 3      None          4
...     ...          ...
10      None          9

当前编码:

inputfile = open("file.txt", 'r')
corpus = [w for w in inputfile]
label = ['a']
corpus_df = {'Document': corpus, 'Category': label}
corpus_df = pd.DataFrame.from_dict(corpus_df, orient='index')
print corpus_df.transpose()

我的问题是如何使其他文档具有与 D1 相同的类别?

标签: python-2.7pandas

解决方案


推荐阅读