hi,
I have a vbar plot that I’m trying to layout by 2 different groups on the xaxis. I’m using a pandas dataframe to read an Excel file with the data.
My outer group is ‘month_end’ and is the names of different months. when I display the plot, the outer group is ordered alphabetically so that “Feb” shows before “Jan”.
My question is, can I use a pandas dataframe and a ColumnDataSource and still order the outer group by the order in which the months are chronologically sequenced? Jan, Feb, March, etc.
df = pd.read_excel('org_compliance_timeseries.xlsx', index_col=0)
df.org = df.org.astype(str)
df.month_end = df.month_end.astype(str)
dfgroup = df.groupby(by=['month_end', 'org'])
source = ColumnDataSource(dfgroup)
# periods = ['Jan', 'Feb']
index_cmap = factor_cmap('month_end_org', palette=OrRd3, factors=sorted(df.month_end.unique()), end=1)
p = figure(title="org by month",
x_range=dfgroup, toolbar_location=None, tooltips=[("Tests Completed", "@total_number_of_tests_completed_mean"), ("month_end, org", "@month_end_org")], plot_width=600)
p.vbar(x='month_end_org', top='total_number_of_tests_completed_mean', width=0.9, source=df2group, line_color="black", fill_color=index_cmap)