Coalesce

Coalesce allows to replace null values with a non-null value. With this transform, you can create a new column that combines values of two columns and replaces any null values in one column with the non-null value from the other column.

tags: [“Data Preparation”]

Parameters

The table gives a brief description about each parameter in Coalesce transform.

Name:

By default, the transform name is populated. You can also add a custom name for the transform.

Input Dataset:

The file name of the input dataset. You can select the dataset that was uploaded from the drop-down list to apply the coalesce (Required: True, Multiple: False)

Coalesced Column:

The new name for the column after the values of two specified columns are combined. (Required: True, Multiple: False, Datatypes: [‘STRING’], Options: [‘CONSTANT’])

First Column:

The name of the first column to apply coalesce. (Required: True, Multiple: False, Datatypes: [‘ANY’], Options: [‘FIELDS’], Datasets: [‘df’])

Second Column:

The name of the second column to apply coalesce. (Required: True, Multiple: False, Datatypes: [‘ANY’], Options: [‘FIELDS’], Datasets: [‘df’])

Output Dataset:

The file name with which the output dataset is created with the coalesced column. (Required: True, Multiple: False)

Sample input for Coalesce transform:

../../../_images/coalesce_input.png

The output after running the Coalesce transform on the dataset appears as below:

../../../_images/coal_output.png

How to use it in Notebook

The following is the code snippet you must use in the Jupyter Notebook editor to run the Coalesce transform:

template=TemplateV2.get_template_by('Coalesce')

recipe_Coalesce= project.addRecipe([car_data, employee_data, temperature_data, only_numeric], name='Coalesce')

transform=Transform()
transform.templateId = template.id
transform.name='Coalesce'
transform.variables = {
'input_dataset':'car',
'new_column_name':"coalesced_column",
'column_1':"curbweight",
'column_2':"carheight",
'output_dataset':'car_coalesce'}
recipe_Coalesce.add_transform(transform)
recipe_Coalesce.run()

Requirements

pandas