how use bokeh vbar chart parameter with groupby object?

本秂侑毒 提交于 2019-12-02 09:31:08

The group = df.groupby(('cyl', 'mfr')) makes a <pandas.core.groupby.DataFrameGroupBy object at 0x0xxx>. If you pass this to a ColumnDataSource, bokeh does a lot of magic, and calculates a lot of statistics already

df.columns
Index(['mpg', 'cyl', 'displ', 'hp', 'weight', 'accel', 'yr', 'origin', 'name', 'mfr'],
source.column_names

['accel_count', 'accel_mean', 'accel_std', 'accel_min', 'accel_25%', 'accel_50%', 'accel_75%', 'accel_max', 'displ_count', 'displ_mean', 'displ_std', 'displ_min', 'displ_25%', 'displ_50%', 'displ_75%', 'displ_max', 'hp_count', 'hp_mean', 'hp_std', 'hp_min', 'hp_25%', 'hp_50%', 'hp_75%', 'hp_max', 'mpg_count', 'mpg_mean', 'mpg_std', 'mpg_min', 'mpg_25%', 'mpg_50%', 'mpg_75%', 'mpg_max', 'weight_count', 'weight_mean', 'weight_std', 'weight_min', 'weight_25%', 'weight_50%', 'weight_75%', 'weight_max', 'yr_count', 'yr_mean', 'yr_std', 'yr_min', 'yr_25%', 'yr_50%', 'yr_75%', 'yr_max', 'cyl_mfr']

  1. the cyl_mfr is the labels of the 2 columns on which you grouped by concatenated. In source this has become a column of tuples

  2. mpg_sum is not calculated. If you cant the sum, you will need to calculate that yourself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!