Skip to content

Latest commit

 

History

History
49 lines (43 loc) · 872 Bytes

142.md

File metadata and controls

49 lines (43 loc) · 872 Bytes
@author jackzhenguo
@desc
@tag
@version 
@date 2020/02/09
import hashlib
import pandas as pd
from wordcloud import WordCloud
geo_data=pd.read_excel(r"../data/geo_data.xlsx")
print(geo_data)
# 0     深圳
# 1     深圳
# 2     深圳
# 3     深圳
# 4     深圳
# 5     深圳
# 6     深圳
# 7     广州
# 8     广州
# 9     广州
#筛选出非空列表值
words = ','.join(x for x in geo_data['city'] if x != []) 
wc = WordCloud(
    background_color="green", #背景颜色"green"绿色
    max_words=100, #显示最大词数
    font_path='./fonts/simhei.ttf', #显示中文
    min_font_size=5,
    max_font_size=100,
    width=500  #图幅宽度
    )
x = wc.generate(words)
x.to_file('../data/geo_data.png') 
[上一个例子](141.md) [下一个例子](143.md)