生成词云

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pandas as pd
import matplotlib.pyplot as plt
from wordcloud import WordCloud

# 读取Excel文件
data = pd.read_excel('index.xlsx')
df = pd.DataFrame(data)

# 从DataFrame中提取数据
text = df['Name']
text1 = ' '.join(df['Name'])
print(text)
print(text1)

# 创建词云对象
wordcloud = WordCloud(background_color='white').generate(text1)

# 展示词云
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()