import matplotlib.pyplot as plt
import pandas as pd
plt.style.use('ggplot')
from wordcloud import WordCloud, STOPWORDS
df = pd.read_excel(r'crawling.xlsx')
text = ''
for row in df.CUSTOMER_CONTENTION_TEXT.values:
text = text + row.value() + ' '
wc = WordCloud(max_words=2000,
stopwords=STOPWORDS, font_path=r'NanumBarunGothic.otf')
# generate word cloud
wc.generate(text)
# store to file
wc.to_file(r'first.png')
# show
plt.imshow(wc)
plt.axis("off")
plt.figure()
plt.axis("off")
plt.show()
我从github [https://gist.github.com/pybokeh/de5475328fb2bbb33cb7]python_wordcloud_from_excel.ipynb
用于df.CUSTOMER_CONTENTION_TEXT.values中的行:
我听不懂。你能解释一下吗?我想修复此代码并使用它,但我不知道如何解决。
这是Excel中的第一行,列值。