staircase.aggregate

staircase.aggregate(collection, func, points=None)

Takes a collection of Stairs instances and returns a single instance representing the aggregation.

Parameters:
  • collection (tuple, list, numpy array, dict or pandas.Series) – The Stairs instances to aggregate
  • func (a function taking a 1 dimensional vector of floats, and returning a single float) – The function to apply, eg numpy.max
  • points (vector of floats or dates) – Points at which to evaluate. Defaults to union of all step changes. Equivalent to applying Stairs.resample().
Returns:

Return type:

Stairs

Notes

The points at which to aggregate will include -infinity whether explicitly included or not.

Examples

>>> import staircase as sc
>>> import numpy as np
>>> stair_list = [s1, s2, sc.aggregate([s1,s2], np.std)]
>>> fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(17,5), sharey=True, sharex=True)
>>> for ax, title, stair_instance in zip(axes, ("s1", "s2", "np.std(s1,s2)"), stair_list):
...     stair_instance.plot(ax)
...     ax.set_title(title)
../_images/staircase-aggregate-1.png