staircase.make_test_data#

staircase.make_test_data(dates: bool = True, positive_only: bool = True, groups: tuple[Optional[str]] | list[Optional[str]] = (), seed: int | None = None) pd.DataFrame#

Creates interval data for use with staircase.

The result will be a pandas.DataFrame with columns “start”, “end”, “value”, and optionally “group”.

Parameters
datesbool, default True

Indicates whether to return data associated with a datetime domain or numerical. If dates is true the data will be confined to the year 2021. If dates is false the data will be confined to the interval [0, 100]

positive_onlybool, default True

If True then value column will only consist of positive values

groupsarray-like of strings, optional

If specified will create data for each string specified in groups. A column named “group” will be added to identify the subsets of data.

seedint, optional

If specified will seed a random number generator to facilitate reproducability.

Returns
pandas.DataFrame

Examples

>>> df = sc.make_test_data()
>>> sc.Stairs(df, "start", "end").plot()
../../_images/staircase-make_test_data-1.png
>>> df = sc.make_test_data(dates=False, positive_only=False, seed=42)
>>> sc.Stairs(df, "start", "end", "value").plot()
../../_images/staircase-make_test_data-2.png
>>> df = sc.make_test_data(groups=["A", "B", "C"])
>>> stairs = df.groupby("group").apply(sc.Stairs, "start", "end")
>>> ax = stairs["A"].plot(label="A")
>>> stairs["B"].plot(ax, label="B")
>>> stairs["C"].plot(ax, label="C")
>>> ax.legend()
../../_images/staircase-make_test_data-3.png