Python 删除系列中的标点符号

Python 删除系列中的标点符号,python,pandas,nlp,data-cleaning,Python,Pandas,Nlp,Data Cleaning,这是我的系列,已标记并删除了停止词: 0 [laptop, sits, 4, stars, similarly, priced, co... 1 [ordered, monitor, wanted, makeshift, area, po... 2 [monitor, great, deal, price, size, ., use, of... 3 [bought, height, adjustment, ., swivel, abili

这是我的
系列
,已标记并删除了停止词:

0        [laptop, sits, 4, stars, similarly, priced, co...
1        [ordered, monitor, wanted, makeshift, area, po...
2        [monitor, great, deal, price, size, ., use, of...
3        [bought, height, adjustment, ., swivel, abilit...
4        [worked, month, died, ., 5, calls, hp, support...
                               ...                        
30618                                        [great, deal]
30619                                  [pour, le, travail]
30620                                      [business, use]
30621                                         [good, size]
30622    [pour, mon, ordinateur.plus, grande, image.vra...
Name: text_body, Length: 30623, dtype: object
我想删除上述系列中的标点符号。我试过这样的东西

filtered_text = re.sub(r'[^\w\s]','',str(series))
结果显示为字符串

我有两个问题

  • 有没有办法将
    过滤的\u文本
    字符串转换回列表或序列
  • 是否有更好的方法从原始系列中删除标点符号

  • 理想情况下,您应该从以下序列中删除
    标点符号

    filtered_text = s.str.replace('[^\w\s]','')
    
    其中
    s
    是您的系列

    说明:

    首先通过
    .str
    将序列转换为字符串,然后应用
    替换
    正则表达式。
    现在您不必担心再次将其转换回
    系列。

    我尝试了您的方法。而且,
    filtered_text
    结果似乎充满了
    NaN
    值。我有办法解决这个问题吗?无论如何,谢谢你的回答,非常感谢。你能在
    结果
    变得
    NaN
    的地方分享更多数据吗?如果问题得到解决,请单击我的答案旁边的
    勾选标记
    ,接受我的答案。