Applymap()

This function uses the earlier loaded mapping table data to replace a field value where it is used. It should be used with the Load statement:

The syntax for using Applymap is Applymap (‘Map Table Name’, Mapping FieldName or Expression, [Default Mapping]).

The following are the arguments passed in the function:

  • Map Table Name: This is the name of the table that has been created earlier using the Mapping prefix. You must enclose the name of the table in single quotes.
  • Mapping FieldName or Expression: This is the field or the expression for which the value should be mapped.
  • Default Mapping: This is an optional parameter that is used when mapping is not found.

For example, imagine you have data with the name of the United States written in a number of different forms, such as USA, U.S., and so on. You want to replace the different values (as shown in following screenshot) to a single value of US. The following screenshot shows the script:

You can see in the preceding screenshot that we have created a mapping table before using the Applymap function. This mapping table has two columns, one for the old value and one for the new value. The old value is the field that contains the value that needs to be replaced, and the new value is the field that contains the value that it needs to be replaced with.

The output of the script is as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset