如何从数据帧的一列中删除标点符号?

问题描述

我正在尝试使用以下代码从“文本”列中删除标点符号:

texttweet = pd.read_csv("../input/pfizer-vaccine-tweets/vaccination_tweets.csv")

i = 0
punct = "\n\r"+string.punctuation

for tweet in texttweet['text']:
    texttweet['text'][i] = tweet.translate(str.maketrans('','',punct))
    i += 1

texttweet

虽然我得到了所需的结果,但我收到了这条消息:

A value is trying to be set on a copy of a slice from a DataFrame

那么无论消息如何都可以保留我的代码还是我应该更改某些内容?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)