sloria / TextBlob

Simple, Pythonic, text processing--Sentiment analysis, part-of-speech tagging, noun phrase extraction, translation, and more.
https://textblob.readthedocs.io/
MIT License
9.17k stars 1.15k forks source link

text argument must be a string not a Series #82

Closed kimkraunz closed 9 years ago

kimkraunz commented 9 years ago

I'm getting the following error when I try to use the sentiment property: The text argument passed to __init__(text) must be a string, not <class 'pandas.core.series.Series'>

I'm trying to run:

text = df['blurb'].apply(str) blob = TextBlob(text) sentiment= blob.sentiment

Can you please advise me how to pass a Series through TextBlob to do sentient analysis. The error seems to be coming from line 2. I've tried to write as a loop but I still get the same error.

avinav commented 9 years ago

Pandas dataframe will return of 'Series' type. And you are trying to create a blob with that type instead of string. Error will be like: The text argument passed to __init__(text) must be a string, not class 'pandas.core.series.Series' Extract the element from the series and then try