plot_holidays

plot_holidays(ts: TSDataset, holidays: Union[str, pandas.core.frame.DataFrame], segments: Optional[List[str]] = None, columns_num: int = 2, figsize: Tuple[int, int] = (10, 5), start: Optional[str] = None, end: Optional[str] = None, as_is: bool = False)[source]

Plot holidays for segments.

Sequence of timestamps with one holiday is drawn as a colored region. Individual holiday is drawn like a colored point.

It is not possible to distinguish points plotted at one timestamp, but this case is considered rare. This the problem isn’t relevant for region drawing because they are partially transparent.

Parameters
  • ts (TSDataset) – TSDataset with timeseries data

  • holidays (Union[str, pandas.core.frame.DataFrame]) –

    there are several options:

    • if str, then this is code of the country in holidays library;

    • if DataFrame, then dataframe is expected to be in prophet`s holiday format;

  • segments (Optional[List[str]]) – segments to use

  • columns_num (int) – number of columns in subplots

  • figsize (Tuple[int, int]) – size of the figure per subplot with one segment in inches

  • as_is (bool) –

    • Use this option if DataFrame is represented as a dataframe with a timestamp index and holiday names columns.
      In a holiday column values 0 represent absence of holiday in that timestamp, 1 represent the presence.

  • start (Optional[str]) – start timestamp for plot

  • end (Optional[str]) – end timestamp for plot

Raises

ValueError:

  • Holiday nor pd.DataFrame or String. * Holiday is an empty pd.DataFrame. * as_is=True while holiday is String. * If upper_window is negative. * If lower_window is positive.