Error sequence item 10: expected str instance, float found while visualization

Viewed 40

The data Dataset Need help, i want make visualization the words with wordcloud but i got this error, i already trying but still stuck and still trying

    # wordcloud
from wordcloud import WordCloud

# Polarity == 0 negative
train_s0 = df_preprocessed[df_preprocessed["label"] == 0]
all_text_s0 = ' '.join(word for word in train_s0["Comment"])
wordcloud = WordCloud(colormap='Reds', width=1000, height=1000, mode='RGBA', background_color='white').generate(all_text_s0)
plt.figure(figsize=(20,10))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.margins(x=0, y=0)
plt.show()

# Polarity == 1 positive
train_s1 = df_preprocessed[df_preprocessed["label"] == 1]
all_text_s1 = ' '.join(word for word in train_s1["Comment"])
wordcloud = WordCloud(width=1000, height=1000, colormap='Blues', background_color='white', mode='RGBA').generate(all_text_s1)
plt.figure( figsize=(20,10))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.margins(x=0, y=0)
plt.show()

the error

TypeError                                 Traceback (most recent call last)
<ipython-input-20-751f25625911> in <module>()
      4 # Polarity == 0 negative
      5 train_s0 = df_preprocessed[df_preprocessed["label"] == 0]
----> 6 all_text_s0 = ' '.join(word for word in train_s0["Comment"])
      7 wordcloud = WordCloud(colormap='Reds', width=1000, height=1000, mode='RGBA', background_color='white').generate(all_text_s0)
      8 plt.figure(figsize=(20,10))

TypeError: sequence item 10: expected str instance, float found
0 Answers
Related