can someone help me !! i have that error "expected string or bytes-like object"

corpus = []
for i in range (117):
    rev=re.sub("[^a-zA-Z]"," ",a.iloc[i,2])
    rev=rev.lower()
    rev=rev.split()
    ps=PorterStemmer()
    rev=[ps.stem(word) for word in rev if not word in set (stopwords.words("french"))]
    rev=" ".join(rev)
    corpus.append(rev)

Here is the error:

> --> 210     return _compile(pattern, flags).sub(repl, string, count)
>     211 
>     212 def subn(pattern, repl, string, count=0, flags=0):
> 
> TypeError: expected string or bytes-like object


Read more here: https://stackoverflow.com/questions/68488568/can-someone-help-me-i-have-that-error-expected-string-or-bytes-like-object

Content Attribution

This content was originally published by Faouzi YAHYAOUI at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: