I filtered largest 5 tweets with max polarity after sentimental analysis.
maxx = df.nlargest(5,['polarity']).astype(str)
maxx
Output:
Unnamed: 0 clean_tweet Tweet_tokenized polarity subjectivity Sentiment_Type scores compound sentiment_type pca
315 315 Best of। luck Biden💪 best / luck biden 1.0 0.3 POSITIVE {'neg': 0.0, 'neu': 0.122, 'pos': 0.878, 'comp... 0.802 POSITIVE [-0.06151099614792966, -0.030998756958434074]
And now I'd like to create some wordcloud
but I'm getting error:
hero.wordcloud(maxx, max_words=100)
AttributeError: 'DataFrame' object has no attribute 'str'
Sorting based on polarity
df['polarity'] = df['polarity'].astype('float')
maxx = df.nlargest(5, 'polarity')
If you are using wordcloud
package try this
from wordcloud import WordCloud
text_data = ' '.join(maxx['clen_tweet'])
wordcloud = WordCloud().generate(text_data)
plt.imshow(wordcloud2)
plt.axis("off")
plt.show()
Using texthero
import texthero as hero
hero.wordcloud(maxx['clean_tweet'], max_words=100)