featuretools.primitives.DistanceToHoliday#

class featuretools.primitives.DistanceToHoliday(holiday="New Year's Day", country='US')[source]#

Computes the number of days before or after a given holiday.

Description:

For a list of dates, return the distance from the nearest occurrence of a chosen holiday. The distance is returned in days. If the closest occurrence is prior to the date given, return a negative number.

If a date is missing, return NaN.

Currently only works with dates between 1950 and 2100.

Parameters:
  • holiday (str) – Name of the holiday. Defaults to New Year’s Day.

  • country (str) – Specifies which country’s calendar to use for the given holiday. Default is US.

Examples

>>> from datetime import datetime
>>> distance_to_holiday = DistanceToHoliday("New Year's Day")
>>> dates = [datetime(2010, 1, 1),
...          datetime(2012, 5, 31),
...          datetime(2017, 7, 31),
...          datetime(2020, 12, 31)]
>>> distance_to_holiday(dates).tolist()
[0, -151, 154, 1]
We can also control the country in which we’re searching for

a holiday.

>>> distance_to_holiday = DistanceToHoliday("Victoria Day", country='Canada')
>>> dates = [datetime(2010, 1, 1),
...          datetime(2012, 5, 31),
...          datetime(2017, 7, 31),
...          datetime(2020, 12, 31)]
>>> distance_to_holiday(dates).tolist()
[143, -10, -70, 144]
__init__(holiday="New Year's Day", country='US')[source]#

Methods

__init__([holiday, country])

flatten_nested_input_types(input_types)

Flattens nested column schema inputs into a single list.

generate_name(base_feature_names)

generate_names(base_feature_names)

get_args_string()

get_arguments()

get_description(input_column_descriptions[, ...])

get_filepath(filename)

get_function()

Attributes

base_of

base_of_exclude

commutative

compatibility

Additional compatible libraries

default_value

Default value this feature returns if no data found.

description_template

input_types

woodwork.ColumnSchema types of inputs

max_stack_depth

name

Name of the primitive

number_output_features

Number of columns in feature matrix associated with this feature

return_type

ColumnSchema type of return

series_library

stack_on

stack_on_exclude

stack_on_self

uses_calc_time

uses_full_dataframe