Pandas Categorical Index with Bokeh high-level charting API

It seems as though Bokeh’s high-level charting API, for instance bokeh.charts.Bar, does not respect the order inherent in a Pandas Categorical Index. One data series I was looking at contained Moody’s ratings (see https://en.wikipedia.org/wiki/Bond_credit_rating#Credit_rating_tiers for the scale). Alphabetical order would place the “A1” value first. When I use bokeh.charts.Bar, in fact, A1 is the first value on the left of the chart.

To solve this, I attempted to use an ordered Pandas categorical index for the series I pass in, which explicitly places “Aaa” first, and “Aa1” second, etc., but this does not seem to change anything in the resulting bar plot.

I will post example code and plots shortly, just wanted to start this discussion, to see what others’ experience has been.

There’s an option to
not sort. I’ve forgotten how to use it - I’m pretty sure it’s in an example somewhere.

···

On 8/27/16 11:26 AM,
wrote:

[email protected]

    It seems as though Bokeh's high-level charting API,

for instance bokeh.charts.Bar, does not respect the order
inherent in a Pandas Categorical Index. One data series I was
looking at contained Moody’s ratings
(see
for the scale). Alphabetical order would place the “A1” value
first. When I use bokeh.charts.Bar, in fact, A1 is the first
value on the left of the chart.

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected]

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/c96983c1-5732-462a-9f3d-88f532ef033e%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/c96983c1-5732-462a-9f3d-88f532ef033e%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

https://en.wikipedia.org/wiki/Bond_credit_rating#Credit_rating_tiers

      To solve this, I attempted to use an ordered Pandas

categorical index for the series I pass in, which explicitly
places “Aaa” first, and “Aa1” second, etc., but this does not
seem to change anything in the resulting bar plot.

        I will post example code and plots shortly, just wanted

to start this discussion, to see what others’ experience has
been.