未显示使用matplotlib的Wordcloud

未显示使用matplotlib的Wordcloud,matplotlib,databricks,word-cloud,Matplotlib,Databricks,Word Cloud,有关我的代码,请参见以下内容: #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',

有关我的代码,请参见以下内容:

#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()
在databricks中,必须使用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>
Out[1106]:
输出[1106]:(-0.5399.5199.5,-0.5)
Out[1106]:
谢谢你的帮助。

您的代码不起作用,tf没有定义策略,正在习惯堆栈溢出。为tf['word']添加了一个初始化,并添加了
导入熊猫为pd
(对我来说,它正在工作)谢谢@RobJan。此代码可以在标准ipython笔记本中使用。我特别对databricks有意见。你有没有在databricks上试过?谢谢。这对我使用jupyter笔记本很有效,但我不确定databricks是怎么回事