Search code examples
python-3.xpandasbokehholoviews

Bokeh or Holoviews: BarChart by downsampling date time to months/years/etc


I have a pandas dataframe (wrapped in holoviews typically) that has three columns. Col1 is a datetime, Col2 are categorical strings (i.e. one of 'Cat', 'Dog', 'Bird'), and Col3 being an integer count.

I'm trying to find a way to use the bokeh library to downsample the datetime to months, quarters, years, etc. similar to that available in pandas.DataFrame.resample or pandas.DataFrame.groupby([pd.Grouper(key='Date', freq=sample)]).

Does anyone know if there is a native bokeh ability to do this, or do I need to provide all the data already sampled from pandas? Thanks!


Solution

  • You will need to do your own downsampling. Bokeh does not generally do any sort of data aggregations itself. The few exceptions are:

    • hexbin to generate data binned on a hex tile grid
    • passing a pandas GroupBy to initialize a CDS will create a CDS with columns for the aggregates

    And even in the second case, arguably it's not Bokeh itself doing the aggragation.