Module: Prophet::Holidays
- Included in:
- Forecaster
- Defined in:
- lib/prophet/holidays.rb
Instance Method Summary collapse
- #get_holiday_names(country) ⇒ Object
-
#holidays_df ⇒ Object
TODO improve performance.
- #make_holidays_df(year_list, country) ⇒ Object
Instance Method Details
#get_holiday_names(country) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/prophet/holidays.rb', line 3 def get_holiday_names(country) years = (1995..2045).to_a holiday_names = make_holidays_df(years, country)["holiday"].uniq if holiday_names.size == 0 raise ArgumentError, "Holidays in #{country} are not currently supported" end holiday_names end |
#holidays_df ⇒ Object
TODO improve performance
17 18 19 20 21 22 |
# File 'lib/prophet/holidays.rb', line 17 def holidays_df @holidays_df ||= begin holidays_file = File.("../../data-raw/generated_holidays.csv", __dir__) Rover.read_csv(holidays_file, converters: [:date, :numeric]) end end |
#make_holidays_df(year_list, country) ⇒ Object
12 13 14 |
# File 'lib/prophet/holidays.rb', line 12 def make_holidays_df(year_list, country) holidays_df[(holidays_df["country"] == country) & (holidays_df["year"].in?(year_list))][["ds", "holiday"]] end |