etna.analysis.plot_holidays#

plot_holidays(ts: TSDataset, holidays: str | DataFrame, segments: List[str] | None = None, columns_num: int = 2, figsize: Tuple[int, int] = (10, 5), start: Timestamp | int | str | None = None, end: Timestamp | int | str | None = 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 (str | DataFrame) –

    there are several options:

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

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

    • if DataFrame and as_is == True, then dataframe is expected to be in a format 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.

  • segments (List[str] | None) – 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) – See holidays parameter

  • start (Timestamp | int | str | None) – start timestamp for plot

  • end (Timestamp | int | str | None) – end timestamp for plot

Raises:
  • ValueError: – Incorrect type of start or end is used according to ts.freq.

  • ValueError: – If holidays nor pd.DataFrame or str.

  • ValueError: – Holiday is an empty pd.DataFrame.

  • ValueError: – If as_is=True while holiday is string.

  • ValueError – If holiday is str and data has integer timestamp

  • ValueError: – If upper_window is negative.

  • ValueError: – If lower_window is positive.