问题描述
我有一个数据集 enter image description here,我想创建一个带有标题和文本的单列。我试着写这样的代码:
df['text'] = df['title'] +" "+ df['text']
#Delete all the other columns.
del df['title'] # added to text corpus
del df['subject'] # it would affect results
del df['date']
但是它不起作用并且我收到错误消息。 enter image description here
解决方法
我认为您正在寻找的线路是:
df['new_text'] = df['title'].str.cat(df['text'],sep=" ")