df = pd.read_excel (r'C:\Users\Desktop\train.xlsx', sheet_name='SunValley')
print (df.head(10))
from wordcloud import WordCloud
text = open(df,'r',encoding='utf-8').read()
wc =WordCloud(
max_font_size=110,
max_words=100,
font_path='C:\Windows\Fonts\simkai.ttf',
background_color="white",
width=800,
height=500,
random_state = 20).generate(str(text))
plt.figure(figsize=(10, 7))
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis('off')
plt.savefig("Wordcloud for comments.png", dpi = 300)
plt.show()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-710a292a210d> in <module>
1 from wordcloud import WordCloud
----> 2 text = open(df,'r',encoding='utf-8').read()
3 wc =WordCloud(
4 max_font_size=110,
5 max_words=100,
TypeError: expected str, bytes or os.PathLike object, not DataFrame
我的excel文档是中文的,想知道哪里错了,怎么改正?谢谢!!