我有一个数据集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=" ")
关于python - 如何创建包含所有相关文本的单个列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65553066/