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

Pandas 要将每列中包含句子的一列数据帧转换为字符串吗,pandas,Pandas,这是我在这里发布的数据框,只是其中的一部分 dataframe=[“想关闭我的卡”、“想停用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 deactiva

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

dataframe=[“想关闭我的卡”、“想停用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))
O/p:

如果您的列有字符串列表,请尝试此操作

df.col.apply(lambda x: x.pop())
试试这个

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))
O/p:

如果您的列有字符串列表,请尝试此操作

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

欢迎来到StackOverflow。请花点时间阅读这篇文章,以及如何提供答案,并相应地修改你的问题。这些提示可能也很有用。欢迎使用StackOverflow。请花点时间阅读这篇文章,以及如何提供答案,并相应地修改你的问题。这些提示可能也很有用。即[“想关闭我的卡”、“想停用emi 44卡”、“想停用55我的bajaj emi卡”、“想停用55我的emi卡”、“想停用77我的bajaj”]我会告诉你我试图把这个数据帧放到countvectorizer中的实际问题是什么,它说这个errorAttributeError:'int'对象没有属性'lower',请把你的问题说清楚。显示您的输入和预期输出。@ParvezSureliya-查看更新的答案。希望这是您想要的。即[“想要关闭我的卡”,“想要停用emi 44卡”,“想要停用55我的bajaj emi卡”,“想要停用55我的emi卡”,“想要停用77我的bajaj”]我会告诉你我试图把这个数据帧放到countvectorizer中的实际问题是什么,它说这个errorAttributeError:'int'对象没有属性'lower',请把你的问题说清楚。显示您的输入和预期输出。@ParvezSureliya-查看更新的答案。希望这是你想要的。