想要将包含每列句子的一列的数据帧转换为字符串



这是数据帧,我只是在这里发布其中的一部分

数据帧 = ["想要关闭我的卡"、"想要停用 EMI 44 卡"、"想要停用 55 我的 Bajaj EMI 卡"、"想要停用 55 我的 EMI 卡"、">

想要停用我的 77 Bajaj Finserv 卡"、"取消我的 EMI 卡的流程是什么"]

那么如何将所有这些转换为字符串值

试试这个,

df=pd.DataFrame({'col':  ['want to close my card', 'want to deactivate emi 44 card', 'want to deactivate 55 my bajaj emi card', 'want to deactivate 55 my emi card', 'want to discontinue my 77 bajaj finserv card', 'what is the process to cancel my emi card']})
print(' '.join(df.col))

操作/操作:

'want to close my card want to deactivate emi 44 card want to deactivate 55 my bajaj emi card want to deactivate 55 my emi card want to discontinue my 77 bajaj finserv card what is the process to cancel my emi card'

如果你的 col 有字符串列表,试试这个。

df.col.apply(lambda x: x.pop())

最新更新