有关我的代码,请参见以下内容:
#tfids words word cloud
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import pandas as pd
tf = pd.DataFrame(columns=['word'])
tf['word'] = ['federalist', 'wrexham', 'remy', 'islamic', 'hegseth', 'hereford', 'gbt', 'sharenet', 'cpr', 'vegas', 'krvn', 'bandidos', 'nginx', 'manafort' , 'roth', 'kennedy' ,'pence', 'quantum']
wordcloud10 = WordCloud().generate(' '.join(tf['word']))
plt.imshow(wordcloud10)
plt.axis("off")
plt.title("")
plt.show()
display()
在数据块中,必须使用显示来查看图表。尽管有上述代码,但我看不到wordcloud。我看到的O / p如下:
Out[1106]: <matplotlib.image.AxesImage at 0x7fae917806d0>
Out[1106]: (-0.5, 399.5, 199.5, -0.5)
Out[1106]: <matplotlib.text.Text at 0x7faeb31a6110>