fillna

Fills the NaN values of a column.

Usage

Fill the NaN values of a column

This calculator can be used with the following method:

fillna

Examples:

  • Fill the quantities of my target variable that are not provided with 0

  • Fill the NA values in the product category column with other value.


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

  • output_columns list of columns added by the calculators

  • 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

  • fill_value Value to use for filling

  • limit Max number of consecutive values to fill


Examples

  1. Let's imagine that our quantity column has NaN values on Saturdays and Sundays, and we want to have 0s for these days. Therefore, we can use the calculator to replace the NaNs with 0s for these two days while limiting the number of consecutive values to be filled to two

    calculated_cols:
      calc_duration:
        method: fillna
        input_columns:
        - qty
        output_columns:
        - filled_col
        params:
          fill_value: 0
          limit: 2

Last updated