I am trying to apply textblob like so:
df['newtext'] = df['text'].apply(lambda x: TextBlob(x))
but that tokenizes "text" and returns (I, ', v, e, , b, e, e, n, , u, s, i, n, g,...) instead of a textblob object. Any idea why this is so?
I am trying to apply textblob like so:
df['newtext'] = df['text'].apply(lambda x: TextBlob(x))
but that tokenizes "text" and returns (I, ', v, e, , b, e, e, n, , u, s, i, n, g,...) instead of a textblob object. Any idea why this is so?
Copyright © 2021 Jogjafile Inc.
Ultimately when you are using the apply method, you are returning a TextBlob object instead of a String and Pandas doesn't know exactly what to do with it (which is why you get the weird behavior)
To solve your issue, simply surround the object being returned by TextBlob with
str(), and it will work. Check the below exampleOutput will look like this:
If you don't use the
str()like:The ouput will look like: