我有一个如下的数据框
Int64Index: 14830 entries, 25791 to 10668
Data columns (total 2 columns):
word 14830 non-null object
coef 14830 non-null float64
dtypes: float64(1), object(1)
我尝试使用系数作为频率而不是计数来制作词云
text = df['word']
WordCloud.generate_from_text(text)
TypeError: generate_from_text() missing 1 required positional argument: 'text'
或者text = np.array(df['word'])
WordCloud.generate_from_text(text)
TypeError: generate_from_text() missing 1 required positional argument: 'text'
我该如何改进这段代码并创建类似于这样的词云图?
from wordcloud import WordCloud
wordcloud = WordCloud( ranks_only= frequency).generate(text)
plt.imshow(wordcloud)
plt.axis('off')
plt.show()
谢谢