featuretools.primitives.DateToHoliday#
- class featuretools.primitives.DateToHoliday(country='US')[source]#
将实例的时间转换为对应的节假日名称(如果有).
- Description:
如果没有节假日,则返回 NaN.目前仅适用于美国和加拿大,日期范围在1950年至2100年之间.
- Parameters:
country (str) – 用于确定节假日的国家. 默认值为 ‘US’.应为以下可用国家之一: 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']
我们也可以更改国家.
>>> 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)将嵌套的列模式输入展平成一个列表.
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_ofbase_of_excludecommutativedefault_valueDefault value this feature returns if no data found.
description_templateinput_typeswoodwork.ColumnSchema types of inputs
max_stack_depthnameName of the primitive
number_output_featuresNumber of columns in feature matrix associated with this feature
return_typeColumnSchema type of return
stack_onstack_on_excludestack_on_selfuses_calc_timeuses_full_dataframe