date_attributes

Extracts date attributes.

Usage

This calculator allows the extraction of different temporal attributes from a date

This calculator can be used with the following method:

date_attributes

Examples:

  • Can be several of: month, day, weekday, iso_weekday, bq_weekday, week, year, iso_week, iso_year, ordinal

  • Looking in differet types of weekday:

    • weekday⇒Monday is 0 and Sunday is 6.

    • iso_weekday⇒ Monday is 1 and Sunday is 7.

    • bq_weekday⇒ Sunday is 1 and Saturday is 7.

  • month is from 1-12.

  • week is the iso-week implementation 8601.

  • iso_week. Equivalent to week. week starts on Monday, and belongs to the year of its Thursday. From 1 to 52/53.

  • iso_year is the iso-year implementation 8601 for the week of your date col. It will correspond to the year of the Thursday in that week.

Please note that iso_week and iso_year can belong to the preceding year, for early January dates. For instance, 2021-01-02 corresponds to iso_year 2020 and iso_week 53.


Main Parameters

The bold options represent the default values when the parameters are optional.

  • input_columns list of columns used as input of the calculators : date column

  • output_columns list of columns added by the calculators : year, iso_year, month, week, iso_week, weekday, iso_weekday, bq_weekday, day, ordinal

  • global (true, false) Should this calculator be performed before data splitting during training for cross-validation

  • steps [optionnal] (training, prediction, postprocessing) List of steps in a pipeline where columns from this calculator are added to the data. Note that when the training option is listed, the calculator is actually added during preprocessing.

  • store_in_model [optionnal] (true, false) Please indicate whether the "calculated" columns by the calculator should be stored in the model or not to avoid recalculating them during prediction. This is only relevant if the calculated columns are added to both training and prediction. Without this parameter, the values will not be stored in the model. The following parameters only make sense if this parameter is set to true.

  • stored_columns [required if store_in_model is true] List indicating the columns to be stored among the output_columns.

  • stored_keys [required if store_in_model is true] List indicating the columns to use for identifying the correct values to join on the data for prediction among the stored values (logically, they are to be chosen from the input_columns).


Specific Parameters

  • None


Examples

  1. Let's suppose that in our dataset where we want to predict quantities, we have access to the receipt_date field. However, we need to calculate averages by aggregating across several date attributes. We can use this calculator to extract what we need for the average calculation.

    calculated_cols:
      date_attributes_feat:
          method: date_attributes
          input_columns:
          - receipt_date
          output_columns:
          - month
          - weekday
          - iso_week
          - iso_year
          - day

Last updated