Skip to content

Add dataframe format converter to plot_holidays #702

Closed
1 task
alex-hse-repository opened this issue May 20, 2022 · 4 comments · Fixed by #708
Closed
1 task

Add dataframe format converter to plot_holidays #702

alex-hse-repository opened this issue May 20, 2022 · 4 comments · Fixed by #708
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@alex-hse-repository
Copy link
Collaborator

alex-hse-repository commented May 20, 2022

🚀 Feature Request

Add dataframe format converter to plot_holidays

Motivation

Make method more convenient for parameters selection

Proposal

  1. Create method prophet_to_etna(holidays: pd.Dataframe) -> pd.Dataframe
    Convert the format of holidays dataframe from Prophet see to the format of plot_holidays
  2. Create method etna_to_prophet(holidays: pd.Dataframe) -> pd.Dataframe
    Do it vice versa

Test cases

No response

Alternatives

No response

Additional context

No response

Checklist

  • I discussed this issue with ETNA Team
@alex-hse-repository alex-hse-repository added enhancement New feature or request important labels May 20, 2022
@alex-hse-repository alex-hse-repository added this to the EDA milestone May 20, 2022
@alex-hse-repository alex-hse-repository changed the title Change dataframe format in plot_holidays Add dataframe format converter to plot_holidays May 20, 2022
@iKintosh
Copy link
Contributor

Why not just make this format default to the library?
We have this exact format for ProphetModel already. Why should we support two different holiday formats?

@iKintosh iKintosh self-assigned this May 24, 2022
@iKintosh
Copy link
Contributor

Actually prophet_to_etna(holidays: pd.Dataframe) -> pd.Dataframe is not possible, since we have to know exactly start and end of TSDataset with data we want to apply these holidays to. Additionally we have to know frequency of TSDataset to build correct holiday_df.

@iKintosh
Copy link
Contributor

I think it should be done like this:

import pandas as pd
from etna.datasets import TSDataset
from etna.analysis import plot_holidays

ts = TSDataset(data_in_etna_format, freq="D")
new_years = pd.DataFrame({
  'holiday': 'New Year',
  'ds': pd.to_datetime(['2015-01-01', '2016-01-01', '2017-01-01', '2018-01-01', '2019-01-01']),
  'lower_window': 10,
  'upper_window': 10,
})
holidays = pd.concat((new_years,))

plot_holidays(ts, holidays=holidays, segments=["Finland_KaggleMart_Kaggle Hat"], columns_num=1, figsize=(10,7))

holiday_plot

@iKintosh
Copy link
Contributor

However I suggest we add converter function from old etna format to current (prophet) format.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants