staircase.sample#
- staircase.sample(collection, x)#
Takes a collection of Stairs instances and evaluates their values across a set of points.
- Parameters
- collectionarray-like, dictionary or pandas.Series
The Stairs instances at which to evaluate
- xscalar or vector data
The points at which to sample the Stairs instances. Must belong to the step function domain.
- Returns
pandas.DataFrame
A dataframe, where rows correspond to the Stairs instances in collection. and columns correspond to the points in x. If collection is a dictionary then the resulting dataframe will be indexed by the dictionary keys. If collection is a
pandas.Series
then the dataframe will have the same index as the series.
See also
Examples
>>> import staircase as sc >>> stairs = [s2, s3] >>> [s2.closed, s3.closed] ["left", "left]
>>> sc.sample(stairs, [2,3,4])) 2 3 4 0 0.0 -1.0 -1.0 1 0.0 NaN -1.0
>>> stairs = {"s2":s2, "s3":s3} >>> sc.sample(stairs, [2,3,4])) 2 3 4 s1 0.0 -1.0 -1.0 s2 0.0 NaN -1.0
>>> index=pd.MultiIndex.from_tuples([("a", "s2"), ("b", "s3")]) >>> stairs = pd.Series([s2,s3], index=index) >>> sc.sample(stairs, [2,3,4], side="left")) 2 3 4 a s1 0.0 -1.0 -1.0 b s2 0.0 NaN -1.0