Module: Prophet::Holidays

Included in:
Forecaster
Defined in:
lib/prophet/holidays.rb

Instance Method Summary collapse

Instance Method Details

#get_holiday_names(country) ⇒ Object



3
4
5
6
# File 'lib/prophet/holidays.rb', line 3

def get_holiday_names(country)
  years = (1995..2045).to_a
  make_holidays_df(years, country)["holiday"].uniq
end

#holidays_dfObject

TODO marshal on installation



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/prophet/holidays.rb', line 13

def holidays_df
  @holidays_df ||= begin
    holidays = {"ds" => [], "holiday" => [], "country" => [], "year" => []}
    holidays_file = File.expand_path("../../data-raw/generated_holidays.csv", __dir__)
    CSV.foreach(holidays_file, headers: true, converters: [:date, :numeric]) do |row|
      holidays["ds"] << row["ds"]
      holidays["holiday"] << row["holiday"]
      holidays["country"] << row["country"]
      holidays["year"] << row["year"]
    end
    Rover::DataFrame.new(holidays)
  end
end

#make_holidays_df(year_list, country) ⇒ Object



8
9
10
# File 'lib/prophet/holidays.rb', line 8

def make_holidays_df(year_list, country)
  holidays_df[(holidays_df["country"] == country) & (holidays_df["year"].in?(year_list))][["ds", "holiday"]]
end