数据预处理

df = df[['job', 'marital']] df = df.groupby(['job', 'marital']).size().reset_index(name='counts')

绘制图表

p = figure(x_range=df['job'].unique(), plot_height=350, title='Marital Status by Job', toolbar_location=None, tools="")

p.vbar(x=df['job']+'_'+df['marital'], top=df['counts'], width=0.9)

p.xgrid.grid_line_color = None p.y_range.start = 0

output_file("marital_status_by_job.html")

show(p)

可视化分析:使用 Python Bokeh 库展现不同职业中婚姻状况的占比

原文地址: https://www.cveoy.top/t/topic/jjXM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录