
我在清理文本時遇到這樣的錯誤,我只是嘗試從網路上跟蹤代碼
def remove_pattern(text, pattern):
r = re.findall(pattern, text)
for i in r:
text = re.sub(i, '', text)
return text
df['remove_user'] = np.vectorize(remove_pattern)(df['Comment'], "@[\w]*")
我得到了這個錯誤:

uj5u.com熱心網友回復:
在這里使用str.replace:
df["remove_user"] = df["Comment"].str.replace(r'\W ', '', regex=True)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/475708.html
標籤:Python python-2.7 机器学习 深度学习
上一篇:ARRAYFORMULA(VLOOKUP(QUERY(IMPORTRANGEs)))代替ARRAYFORMULA(QUERY(IMPORTRANGEs))不起作用
