1

Note from maintainers: this question is about the obsolete bokeh.charts API removed several years ago. For an example of timeseries charts in modern Bokeh, see here:

https://docs.bokeh.org/en/latest/docs/gallery/range_tool.html


I'm trying to create a timeseries graph with bokeh. This is my first time using bokeh, and my first time dealing with pandas as well. Our customers receive reviews on their products. I'm trying to create a graph which shows how their average review rating has changed over time.

Our database contains the dates of each review. We also have the average review value for that date. I need to plot a line with the x axis being dates and the y axis being the review value range (1 through 10).

When I accepted this project I thought it would be easy. How wrong I was. I found a timeseries example that looks good. Unfortunately, the example completely glosses over what is the most difficult part about creating a solution. Specifically, it does not show how to create an appropriate data structure from your source data. The example is retrieving pre-built datastructures from the yahoo api. I've tried examining these structures, but they don't exactly look straightforward to me.

I found a page explaining pandas structs. It is a little difficult for me to understand. Particularly confusing to me is how to represent points in the graph without necessarily labeling those points. For example the y axis should display whole numbers, but data points need not intersect with the whole number value. The page I found is linked below:

http://pandas.pydata.org/pandas-docs/stable/dsintro.html

Does anyone know of a working example for the timeseries chart type which exemplifies how to build the necessary data structure?

UPDATE: Thanks to the answer below I toyed around with just passing lists into lines. It didn't occur to me that I could do this, but it works very well. For example:

    date = [1/11/2011, 1/12/2011. 1/13/2011, 4/5/2014]
    rating = [4, 4, 5, 2]
    line(
        date,                                       # x coordinates
        rating,                                  # y coordinates
        color='#A6CEE3',                                    # set a color for the line
        x_axis_type = "datetime",                           # NOTE: only needed on first
        tools="pan,wheel_zoom,box_zoom,reset,previewsave"   # NOTE: only needed on first
    )

1 Answer 1

4

You don't have to use Pandas, you simply need to supply a sequence of x-values and a sequence of y-values. These can be plain Python lists of numbers, or NumPy arrays, or Pandas Series. Here is another time series example that uses just NumPy arrays:

http://docs.bokeh.org/en/latest/docs/gallery/color_scatter.html

EDIT: link updated

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.