featuretools.primitives.DateToHoliday#
- class featuretools.primitives.DateToHoliday(country='US')[source]#
Transforms time of an instance into the holiday name, if there is one.
- Description:
If there is no holiday, it returns NaN. Currently only works for the United States and Canada with dates between 1950 and 2100.
- Parameters:
country (str) – Country to use for determining Holidays. Default is ‘US’. Should be one of the available countries here: https://github.com/dr-prodigy/python-holidays#available-countries
Examples
>>> from datetime import datetime >>> date_to_holiday = DateToHoliday() >>> dates = pd.Series([datetime(2016, 1, 1), ... datetime(2016, 2, 27), ... datetime(2017, 5, 29, 10, 30, 5), ... datetime(2018, 7, 4)]) >>> date_to_holiday(dates).tolist() ["New Year's Day", nan, 'Memorial Day', 'Independence Day']
We can also change the country.
>>> date_to_holiday_canada = DateToHoliday(country='Canada') >>> dates = pd.Series([datetime(2016, 7, 1), ... datetime(2016, 11, 15), ... datetime(2018, 12, 25)]) >>> date_to_holiday_canada(dates).tolist() ['Canada Day', nan, 'Christmas Day']
Methods
__init__
([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
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
stack_on
stack_on_exclude
stack_on_self
uses_calc_time
uses_full_dataframe