Map

This transform maps specified values of selected attributes with new values derived in a dictionary form and creates a new column with the substituted values.

tags: [“Data Preparation”]

Parameters

The table gives a brief description about each parameter in Map 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. (Required: True, Multiple: False)

Output Dataset:

The file name with which the output dataset is created with a new column having substituted values. (Required: True, Multiple: False)

Map dictionary:

The dictionary for mapping. Ex: {‘gas’ : ‘g’} (Required: True, Multiple: False, Datatypes: [“STRING”])

Column:

The column name from where the values are selected to substitute with new values. (Required: True, Multiple: False, Datatypes: [“STRING”], Options: [‘FIELDS’], Datasets: [‘df’])

New Column:

The new column to be created with substituted values. (Required: True, Multiple: False, Datatypes: [“STRING”], Options: [‘CONSTANT’])

The sample input for this transform looks as shown in the screenshot.

../../../_images/map_input.png

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

../../../_images/map_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 Map transform:

template=TemplateV2.get_template_by('Map')

recipe_Map= project.addRecipe([car_data, employee_data, temperature_data, only_numeric], name='Map')

transform=Transform()
transform.templateId = template.id
transform.name='Map'
transform.variables = {
'input_dataset':'car',
'output_dataset':'Mapped',
'dic':"{'two':'t','four':'f'}",
'col':"doornumber",
'new_column':"door_new"}
recipe_Map.add_transform(transform)
recipe_Map.run()

Requirements

pandas json