程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Pandas+Pyecharts | 40000+條考研信息數據可視化

編輯:Python

考研數據集:數據集下載
運行工具:jupyter notebook

前言

博文通過分析各大高校考研招生信息數據,看看:

  • 招生專業最多的10大高校是哪些
  • 專業最高分、最低分分布情況
  • 幾大專業專業TOP20學校有哪些

希望對小伙伴們有所幫助,如有疑問或者需要改進的地方可以在評論區留言。

涉及到的庫:
Pandas — 數據處理
Pyecharts — 數據可視化

可視化部分:
柱狀圖 — Bar
象形圖 — PictorialBar
詞雲圖 — stylecloud
組合組件 — Grid

1. 導入模塊

!pip install stylecloud
import re
import stylecloud
from PIL import Image
import numpy as np
import pandas as pd
from collections import Counter
from pyecharts.charts import Line,PictorialBar,Bar,Grid
from pyecharts import options as opts
from pyecharts.globals import ThemeType
from pyecharts.globals import SymbolType
from pyecharts.commons.utils import JsCode

2.Pandas數據處理

2.1 讀取數據

df = pd.read_csv('/home/mw/input/202201106373/考研信息.csv')
df.head(10)

2.2 查看索引、數據類型和內存信息

df.info()


可以看到,學校名稱、院系名稱、專業代碼等列存在部分數據缺失

2.3 去掉空行

df.dropna(inplace=True)

2.4 篩選2020年考研信息

df_2020 = df[df['年份'] == 2020]
df_2020.info()


可以看到,沒有缺失數據了

2.5 查看所有列都重復的行

df_2020.duplicated().sum()

2.6 查看某些列重復的行

df_2020.duplicated(subset=["學校名稱","專業代碼"]).sum()

2.7 總分行格式處理

df_2020 = df_2020[~(df_2020['總分']=='-')]
df_2020['總分'] = df_2020['總分'].astype('int')
df_2020.info()

3. Pyecharts數據可視化

3.1 招生專業最多的10大高校

df_major_10 = df_2020.groupby('學校名稱')['專業名稱'].count().sort_values(ascending = False)[:10].to_frame('數量')
df_major_10 = df_major_10 = df_major_10.sort_values(by='數量').sort_values(by='數量')
schs = list(df_major_10.index)
sch_icons = {

'武漢大學': 'image://https://www.shanghairanking.cn/_uni/logo/46182017.png',
'吉林大學': 'image://https://www.shanghairanking.cn/_uni/logo/76557044.png',
'廈門大學': 'image://https://www.shanghairanking.cn/_uni/logo/14008229.png',
'西南大學': 'image://https://www.shanghairanking.cn/_uni/logo/68012227.png',
'北京大學': 'image://https://www.shanghairanking.cn/_uni/logo/86350223.png',
'四川大學': 'image://https://www.shanghairanking.cn/_uni/logo/75651370.png',
'山東大學': 'image://https://www.shanghairanking.cn/_uni/logo/97189370.png',
'復旦大學': 'image://https://www.shanghairanking.cn/_uni/logo/28312850.png',
'雲南大學': 'image://https://www.shanghairanking.cn/_uni/logo/31586909.png',
'南開大學': 'image://https://www.shanghairanking.cn/_uni/logo/44629152.png'
}
icons = []
for sch in schs:
icons.append(dict(name=sch, value=1, symbol=sch_icons[sch]))
p1 = (
PictorialBar()
.add_xaxis(schs)
.add_yaxis("",
icons,
label_opts=opts.LabelOpts(is_show=False),
category_gap='40%',
symbol_pos='start',
symbol_size=60,
is_symbol_clip=False,
itemstyle_opts={
"normal": {

'shadowBlur': 10,
'shadowColor': 'rgba(0, 0, 0, 0.5)',
'shadowOffsetX': 10,
'shadowOffsetY': 10,}
})
.set_global_opts(
xaxis_opts=opts.AxisOpts(is_show=False),
yaxis_opts=opts.AxisOpts(
is_show=True,
is_scale=True,
axistick_opts=opts.AxisTickOpts(is_show=False),
axislabel_opts=opts.LabelOpts(font_size=20,color='#ed1941',font_weight=700,margin=20),
splitline_opts=opts.SplitLineOpts(is_show=False,
linestyle_opts=opts.LineStyleOpts(type_='dashed')),
axisline_opts=opts.AxisLineOpts(is_show=False,
linestyle_opts=opts.LineStyleOpts(width=2, color='#DB7093'))
),
)
.reversal_axis()
)
b1 = (
Bar()
.add_xaxis(schs)
.add_yaxis('', df_major_10['數量'].values.tolist(), category_gap='40%')
.set_series_opts(
label_opts=opts.LabelOpts(
position="insideLeft",
vertical_align='middle',
horizontal_align='top',
font_size=18,
font_weight='bold',
formatter=' {c} '),
itemstyle_opts={

'opacity': 0.9,
'shadowBlur': 10,
'shadowOffsetX': 10,
'shadowOffsetY': 10,
'shadowColor': 'rgba(0, 0, 0, 0.5)',
'barBorderRadius': [30, 30, 30, 30],
'color':'red'
}
)
.set_global_opts(
yaxis_opts=opts.AxisOpts(is_show=False),
xaxis_opts=opts.AxisOpts(
is_scale=True,
type_="value",
name_location="middle",
position='top',
name_textstyle_opts=opts.TextStyleOpts(font_size=14, font_weight='bold',),
axisline_opts=opts.AxisLineOpts(is_show=False),
axislabel_opts=opts.LabelOpts(is_show=False),
splitline_opts=opts.SplitLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),),
title_opts=opts.TitleOpts(title='招生專業數量前十的學校',
title_textstyle_opts=opts.TextStyleOpts(color="blue",font_size=30),
pos_top='2%',pos_left = 'center'),
)
.reversal_axis()
)
grid = Grid(init_opts=opts.InitOpts(theme='light', width='1000px', height='800px'))
grid.add(p1, is_control_axis_index=False, grid_opts=opts.GridOpts(pos_left='15%', pos_right='80%', pos_top='10%'))
grid.add(b1, is_control_axis_index=False, grid_opts=opts.GridOpts(pos_left='23%', pos_right='10%', pos_top='10%'))
grid.render_notebook()

3.2 部分專業最高分、最低分分布

df_tmp = df_2020[df_2020["專業名稱"].str.contains('計算機科學與技術|工商管理|會計|管理科學與工程|金融|法律|材料科學與工程|公共管理|機械工程|數學')]
df_major = df_tmp.groupby('專業名稱')['總分'].agg([np.mean, np.max,np.min])
df_major = df_major.sort_values(by=['mean'],ascending=False)[:20]
df_major['amin'] = df_major['amin']*(-1)
bar = (
Bar()
.add_xaxis(df_major.index.tolist())
.add_yaxis('最高分',
df_major['amax'].tolist()[::-1],
z_level=1,
stack='1',
category_gap='50%',
tooltip_opts=opts.TooltipOpts(is_show=False),
label_opts=opts.LabelOpts(position='insideLeft', formatter='{c} 分'),
itemstyle_opts={
"normal": {

"barBorderRadius": [30, 30, 30, 30],
'shadowBlur': 10,
'shadowColor': 'rgba(120, 36, 50, 0.5)',
'shadowOffsetY': 5,
'color':'#a61e4d',
}
}
)
.add_yaxis('最低分',
df_major['amin'].tolist()[::-1],
z_level=1,
stack='1',
category_gap='50%',
tooltip_opts=opts.TooltipOpts(is_show=False),
label_opts=opts.LabelOpts(position='insideRight',
formatter=JsCode(
"""function(params) { if (params.value && params.value < 0) { return -params.value + '分'; } }"""
),
),
itemstyle_opts={
"normal": {

"barBorderRadius": [30, 30, 30, 30],
'shadowBlur': 10,
'shadowColor': 'rgba(120, 36, 50, 0.5)',
'shadowOffsetY': 5,
'color':'#009ad6',
}
}
)
.set_global_opts(title_opts=opts.TitleOpts(title='部分專業的最高分和最低分',pos_top='1%',pos_left='40%',
title_textstyle_opts=opts.TextStyleOpts(font_size=20,color='#fff000')),
legend_opts=opts.LegendOpts(is_show=True, pos_top='4%',pos_left='45%'),
datazoom_opts=opts.DataZoomOpts(type_='inside',
range_start=10, # 設置起止位置,50%-100%
range_end=100,
orient='vertical'),
xaxis_opts=opts.AxisOpts(is_show=False, max_=500),
yaxis_opts=opts.AxisOpts(axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
axislabel_opts=opts.LabelOpts(color='#00c6d7', font_size=12, font_weight='bold')),
)
).reversal_axis()
grid = (
Grid(init_opts=opts.InitOpts(theme='purple-passion', width='1000px', height='800px'))
.add(bar, grid_opts=opts.GridOpts(pos_top='8%', pos_left='18%', pos_right='5%'))
)
grid.render_notebook()

3.3 部分專業考研總分要求最高的前20大高校

3.3.1 計算機科學與技術專業TOP20學校

color_js = """new echarts.graphic.LinearGradient(0, 1, 0, 0, [{offset: 0, color: '#FFFFFF'}, {offset: 1, color: '#ed1941'}], false)"""
range_colors=['#fff5f0','#fee0d2','#fcbba1','#fc9272','#fb6a4a','#ef3b2c','#cb181d','#99000d']
df_computer = df_2020.loc[df_2020['專業名稱']=='計算機科學與技術',:]
df_computer = df_computer.sort_values(by='總分',ascending=False)[:20]
df_computer['總分'] = df_computer['總分'].astype('int')
df_computer.style.bar(subset=['總分'],color='#ed1941', vmin=300, vmax=360)

x_data = df_computer['學校名稱'].values.tolist()
y_data = df_computer['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=360,
min_=300,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='計算機科學與技術專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=400,
min_=200,
range_color=range_colors
),
)
)
bar2.render_notebook()

3.3.2 管理科學與工程專業TOP20學校

df_management = df_2020.loc[df_2020['專業名稱'].str.contains('管理科學與工程'),:]
df_management = df_management.sort_values(by='總分',ascending=False)[:20]
x_data = df_management['學校名稱'].values.tolist()
y_data = df_management['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=405,
min_=360,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='管理科學與工程專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=410,
min_=360,
range_color=range_colors
),
)
)
bar2.render_notebook()

3.3.3 會計專業TOP20學校

df_accountant = df_2020.loc[df_2020['專業名稱'].str.contains('會計'),:]
df_accountant = df_accountant.sort_values(by='總分',ascending=False)[:20]
x_data = df_accountant['學校名稱'].values.tolist()
y_data = df_accountant['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=400,
min_=350,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='會計專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=400,
min_=350,
range_color=range_colors
),
)
)
bar2.render_notebook()

3.3.4 工商管理專業TOP20學校

df_mba = df_2020.loc[df_2020['專業名稱'].str.contains('工商管理'),:]
df_mba = df_mba.sort_values(by='總分',ascending=False)[:20]
x_data = df_mba['學校名稱'].values.tolist()
y_data = df_mba['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=390,
min_=340,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='工商管理專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=390,
min_=340,
range_color=range_colors
),
)
)
bar2.render_notebook()

3.3.5 法律專業TOP20學校

df_law = df_2020.loc[df_2020['專業名稱'].str.contains('法律'),:]
df_law = df_law.sort_values(by='總分',ascending=False)[:20]
x_data = df_law['學校名稱'].values.tolist()
y_data = df_law['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=380,
min_=350,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='法律專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=380,
min_=350,
range_color=range_colors
),
)
)
bar2.render_notebook()

3.3.6 金融專業TOP20學校

df_finance = df_2020.loc[df_2020['專業名稱'].str.contains('金融'),:]
df_finance = df_finance.sort_values(by='總分',ascending=False)[:20]
x_data = df_mba['學校名稱'].values.tolist()
y_data = df_mba['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=390,
min_=340,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='金融專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=390,
min_=350,
range_color=range_colors
),
)
)
bar2.render_notebook()

3.3.7 材料科學與工程專業TOP20學校

df_materials = df_2020.loc[df_2020['專業名稱'].str.contains('材料科學與工程'),:]
df_materials = df_materials.sort_values(by='總分',ascending=False)[:20]
x_data = df_materials['學校名稱'].values.tolist()
y_data = df_materials['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=340,
min_=290,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='材料科學與工程專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=340,
min_=290,
range_color=range_colors
),
)
)
bar2.render_notebook()

3.3.8 機械工程專業TOP20學校

df_mechanical = df_2020.loc[df_2020['專業名稱'].str.contains('機械工程'),:]
df_mechanical = df_mechanical.sort_values(by='總分',ascending=False)[:20]
x_data = df_mechanical['學校名稱'].values.tolist()
y_data = df_mechanical['總分'].values.tolist()
bar2 = (
Bar(init_opts=opts.InitOpts(theme='chalk',width='1000px', height='800px'))
.add_xaxis(x_data)
.add_yaxis('', y_data,
category_gap='30%',
itemstyle_opts={

'normal': {

'shadowColor': 'rgba(0, 0, 0, .5)',
'shadowBlur': 5,
'shadowOffsetY': 2,
'shadowOffsetX': 2,
'borderColor': '#fff'
}
}
)
.set_series_opts(label_opts=opts.LabelOpts(font_weight='bold',font_size=12, color='#66d9e8' ))
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-30,font_size=12,font_weight='bold', color="#41b6c4",margin=10),
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False),
),
yaxis_opts=opts.AxisOpts(is_show=False,
max_=360,
min_=290,
axisline_opts=opts.AxisLineOpts(is_show=False),
axistick_opts=opts.AxisTickOpts(is_show=False)
),
title_opts=opts.TitleOpts(
title='機械工程專業 TOP20 學校',
pos_left='center',
pos_top='4%',
title_textstyle_opts=opts.TextStyleOpts(color='#fec44f', font_size=24, font_weight='bold')
),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_=360,
min_=290,
range_color=range_colors
),
)
)
bar2.render_notebook()

4 學校名稱、專業名稱詞雲

4.1 學校名稱詞雲

schools = df_2020['學校名稱'].values.tolist()
pic_name = '學校名稱.png'
stylecloud.gen_stylecloud(
text=' '.join(schools),
font_path=r'/home/mw/input/202201106373/STXINWEI.TTF',
palette='cartocolors.qualitative.Bold_5',
max_font_size=100,
icon_name='fas fa-graduation-cap',
background_color='#212529',
output_name=pic_name,
)
Image.open(pic_name)

4.2 專業名稱詞雲

major = df_2020['專業名稱'].values.tolist()
pic_name = '專業名稱.png'
stylecloud.gen_stylecloud(
text=' '.join(major),
font_path=r'/home/mw/input/202201106373/STXINWEI.TTF',
palette='cartocolors.qualitative.Bold_5',
max_font_size=100,
icon_name='fas fa-book-open',
background_color='#212529',
output_name=pic_name,
)
Image.open(pic_name)


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved