我尝试过:
library(dplyr)
library(stringr)
df %>%
mutate(new_B = str_replace_all(B, str_replace(A, " ", "|"), ''))
但是我得到了错误:from autocorrect import Speller
spell = Speller(lang='en')
df['Text'] = df['Text'].apply(lambda x: spell(x))
答案 0 :(得分:0)
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)