x = ['18岁以下', '18~25岁', '25~35岁', '35~45岁', '45~55岁', '55岁以上'] y = user_age_df['user_age_count'] trace = go.Bar( x = x, y = y, text=y, textposition='outside') layout = go.Layout( title = dict(text='用户年龄分布',x=0.5),
y = user_region_df['province_name'][::-1] # 切片方法,让列表反向。两个冒号分隔为{起始位置:终止位置:步长} x = user_region_df['region_count'][::-1] # 其中步长为正,从左往右取,步长为负,从右往左取 trace = go.Bar( x = x, y = y, text=x, textposition='outside', orientation = 'h') layout = go.Layout( title = dict(text='用户的地域分布',x=0.5)
) fig = go.Figure(data=trace,layout=layout) fig
y = user_city_df['ulp_addr_city'][::-1] x = user_city_df['city_count'][::-1] trace = go.Bar( x = x, y = y, text=x, textposition='outside', orientation = 'h') layout = go.Layout( title = dict(text='用户的城市分布',x=0.5)
y = user_edu_df['edu'] x = x = ['初中及以下', '高中(中专)', '大学(专科及本科)', '研究生(硕士及以上)'] trace = go.Bar( x = x, y = y, text=y, textposition='outside') layout = go.Layout( title = dict(text='用户的学历分布',x=0.5)
) fig = go.Figure(data=trace,layout=layout) fig
x = ['金融从业者', '医务人员', '公务员/事业单位', '白领/一般职员', '工人/服务业人员', '教师', '互联网从业人员', '学生'] y = user_profession_df['profession'] trace = go.Bar( x = x, y = y, text=y, textposition='outside') layout = go.Layout( title = dict(text='用户的学历分布',x=0.5)
y = user_order_cate_df['item_third_cate_name'][::-1] x = user_order_cate_df['cate_count'][::-1] trace = go.Bar( x = x, y = y, text=x, textposition='outside', orientation = 'h') layout = go.Layout( title = dict(text='用户购买商品分布',x=0.5)
x = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'] y = user_order_week_df_2['week_count'] trace = go.Scatter( x = x, y = y, mode = 'lines', # 折线图 line = dict( width = 2 ) ) layout = go.Layout( title = dict(text='用户购买的日期分布',x=0.5))
fig = go.Figure(data=trace,layout=layout) fig
x = [str(x) for x in range(0, 24)] y = user_order_hms_df['hms_count'] trace = go.Scatter( x = x, y = y, mode = 'lines', # 折线图 line = dict( width = 2 ) ) layout = go.Layout( title = dict(text='用户购买的时间分布',x=0.5), xaxis=dict( tickmode='linear')) fig = go.Figure(data=trace,layout=layout) fig
x = ['不敏感', '轻度敏感', '中度敏感', '高度敏感', '极度敏感'] y = user_order_sens_promotion_df['sens_promotion_count'] trace = go.Bar( x = x, y = y, text=y, textposition='outside') layout = go.Layout( title = dict(text='用户价格敏感度分布',x=0.5)
) fig = go.Figure(data=trace,layout=layout) fig
x = ['不敏感', '轻度敏感', '中度敏感', '高度敏感', '极度敏感'] y = user_order_sens_comment_df['sens_comment_count'] trace = go.Bar( x = x, y = y, text=y, textposition='outside') layout = go.Layout( title = dict(text='用户频率敏感度分布',x=0.5)