以下为python语言请用bokeh库生成如何对duration进行精度为02的预处理subscribe无需处理统计duration和subscribe的关系并生成可视化图from bokehplotting import figure showoutput_fileimport numpy as npimport pandas as pdimport pandasdf = pdread_csvr
对duration进行精度为0.2的预处理
df['duration'] = df['duration'].apply(lambda x: round(x/0.2)*0.2)
统计duration和subscribe的关系
duration_subscribe = df.groupby('duration')['subscribe'].mean()
生成可视化图
p = figure(title='Duration vs Subscribe', x_axis_label='Duration', y_axis_label='Subscribe Rate') p.line(duration_subscribe.index, duration_subscribe.values) output_file('duration_subscribe.html') show(p)
原文地址: https://www.cveoy.top/t/topic/e9Cn 著作权归作者所有。请勿转载和采集!