> For the complete documentation index, see [llms.txt](https://doc.verteego.com/verteego-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.verteego.com/verteego-doc/pipelines/forecasting-pipelines/calculators/temporal/date_attributes.md).

# date\_attributes

Extracts date attributes.

## Usage

{% hint style="info" %}
This calculator allows the extraction of different temporal attributes from a date
{% endhint %}

This calculator can be used with the following method:

<mark style="color:red;">**`date_attributes`**</mark>

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:&#x20;
  * `weekday`⇒Monday is 0 and Sunday is 6.&#x20;
  * `iso_weekday`⇒ Monday is 1 and Sunday is 7.&#x20;
  * `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

{% hint style="success" %}
**The bold options** represent the default values when the parameters are optional.
{% endhint %}

* *<mark style="color:blue;">input\_columns</mark>* \
  list of columns used as input of the calculators : date column
* *<mark style="color:blue;">output\_columns</mark>* \
  list of columns added by the calculators : **`year`, `iso_year`, `month`, `week`, `iso_week`, `weekday`, `iso_weekday`, `bq_weekday`, `day`, `ordinal`**
* *<mark style="color:blue;">global</mark>* *(true, **false)*** \
  Should this calculator be performed before data splitting during training for cross-validation
* *<mark style="color:blue;">steps</mark>* \[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.
* *<mark style="color:blue;">store\_in\_model</mark>* \[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*.
* *<mark style="color:blue;">stored\_columns</mark>* \[required if *<mark style="color:blue;">store\_in\_model</mark> is true*] \
  List indicating the columns to be stored among the *<mark style="color:blue;">output\_columns</mark>*.
* *<mark style="color:blue;">stored\_keys</mark>* \[required if *<mark style="color:blue;">store\_in\_model</mark> 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 *<mark style="color:blue;">input\_columns</mark>*).

***

## Specific Parameters

* *<mark style="color:blue;">None</mark>*

***

## 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.

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