henchman.plotting.timeseries

henchman.plotting.timeseries(col_1, col_2, col_max=None, col_min=None, n_bins=10, aggregate='mean', figargs=None)[source]

Creates a time based aggregations of a numeric variable. This function allows for the user to mean, count, sum or find the min or max of a second variable with regards to a timeseries.

Parameters:
  • col_1 (pd.Series) – The column from which to create bins. Must be a datetime.
  • col_2 (pd.Series) – The column to aggregate.
  • col_max (pd.datetime) – The maximum value for the x-axis. Default is None.
  • col_min (pd.datetime) – The minimum value for the x-axis. Default is None.
  • n_bins (int) – The number of time bins to make.
  • aggregate (str) – What aggregation to do on the numeric column. Options are ‘mean’, ‘sum’, ‘count’, ‘max’ and ‘min’. Default is ‘mean’.

Example

If the dataframe X has a columns named amount and date.

>>> import henchman.plotting as hplot
>>> plot = hplot.timeseries(X['date'], X['amount'])
>>> hplot.show(plot)

For a bokeh plot without sliders:

>>> plot2 = hplot.timeseries(X['date'], X['amount'], n_bins=50)
>>> hplot.show(plot2, static=True)