删除大 pandas 中的标点符号 [英] Remove punctuations in pandas
本文介绍了删除大 pandas 中的标点符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
code: df['review'].head()
index review
output: 0 These flannel wipes are OK, but in my opinion
我想从数据框的列中删除标点符号,然后创建一个新列.
I want to remove punctuations from the column of the dataframe and create a new column.
code: import string
def remove_punctuations(text):
return text.translate(None,string.punctuation)
df["new_column"] = df['review'].apply(remove_punctuations)
Error:
return text.translate(None,string.punctuation)
AttributeError: 'float' object has no attribute 'translate'
我正在使用python 2.7.任何建议都会有所帮助.
I am using python 2.7. Any suggestions would be helpful.
推荐答案
使用
这篇关于删除大 pandas 中的标点符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文