python - 如何创建包含所有相关文本的单个列?

标签 python machine-learning scikit-learn compiler-errors calculated-columns

我有一个数据集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/

相关文章:

machine-learning - 如何随机打乱 Pytorch 数据集的标签?

python - 分层KFold : IndexError: too many indices for array

python - 高斯过程 scikit-learn - 异常

python - RPI dht22 带 flask : Unable to set line 4 to input - Timed out waiting for PulseIn message

python-3.x - tensorflow 模型.负载问题

python - Django迁移1100万行,需要分解

machine-learning - 我应该使用什么类型的神经网络?

python - 在 sklearn NearestNeighbor 中使用每个邻居一次

Python 2.7 - statsmodels - 格式化和编写摘要输出

Python if 语句效率