Hello, I need some help categorizing my horizontal bar chart

I have a multi-index dataframe in pandas which I am trying to convert to a ColumnDataSource in Bokeh. Once this is complete I am attempting to create a bar chart with each bar in a certain category.

I have attempted to use groupby, which displays the correct axes, but then all of the bars disappear.

Below I show the working code, without multi-indexing:

wf = pd.read_csv('test.csv')

# Get Parameter Names for Y Axis Labels and group
wf['parameter'] = wf.iloc[:,0].astype(str)
y_axis_labels = wf['parameter']
y_axis_labels = [x for x in y_axis_labels[::-1]]  # labels must be inversed,

# Get Truncated X Axis Range
x_axis_range_full = list(wf['y_start'])
x_axis_range_without_zero = list(filter(lambda a: a != 0, x_axis_range_full))
x_axis_range_lower = min(x_axis_range_without_zero) - 50
x_axis_range_upper = 1.05 * max(x_axis_range_full)

# Get column data source as variable source
source = ColumnDataSource(wf)
grouped = wf.groupby(by=['group', 'parameter'])

# Create Figure
p = figure(y_range=y_axis_labels,
           x_range=(1000, x_axis_range_upper),
           plot_width=1800, plot_height=1000,
           toolbar_location=None,
           title="PV System Waterfall Chart")

# Add in Horizontal Bars
p.hbar(y='parameter',
       left='y_start',
       right='running_total',
       height=0.85,
       color='color',
       source=source)

The code above works correctly and shows all of the bars without categorization. I have attached another picture which shows the correct axes, but with all of the bars which have disappeared.

working examplebroken example

I suggest you change the ordering. Run the groupby on the original DataFrame. That creates a collection, an interable in which each piece is 2 elements, a key label and the small dataframe for that subset. Grab out the subset you want and make the ColumnDataSource with that. I’d do it this way because it is easier for me to inspect the Python information and verify the grouped data in ordinary Pandas code, rather than the bokeh CDS.

Good luck

Without a complete example to run that reproduces the usage issue, it’s hard to say much. In general all I can suggest is that the coordinates in the case of nested categories should be lists/tuples, e.g the y-coordinates of the bars need to look like ['DC', 'Mismatch'] So the first thing you should do is inspect the y-coordinates you are putting in the CDS for the hbar and see if they look like that or not.