我尝试过:
from autocorrect import Speller
spell = Speller(lang='en')
df['Text'] = df['Text'].apply(lambda x: spell(x))
但是我得到了错误:TypeError: expected string or bytes-like object
[df['Text']
中的某些值可能既不是str
也不是bytes
。试试这个:
from autocorrect import Speller
spell = Speller(lang='en')
df['Text'] = df['Text'].apply(
lambda x: spell(x) if isinstance(x, str) or isinstance(x, bytes) else x)