In this example, the CSV Generator Snap contains sample data with numeric fields. The Copy Snap duplicates the data flow and feeds it into the Numeric to Categorical and Profile Snaps. The Profile Snap generates input data statistics and feeds them into the Numeric to Categorical Snap. The Numeric to Categorical Snap then converts the numeric values in the fields of your choice into categorical values, based on the splitting method you select.
Enter the following data into the CSV Generator Snap:
First, we need to convert values in $experience into numeric values. We do this using a Type Converter Snap with the Auto check box selected.
We want to categorize employees based on their years of experience into "junior", "senior", and "principal". We choose Binning in the Rule property to ensure that the data ranges after splitting are equally spaced.
The Numeric to Categorical Snap contains the following settings:
The Profile Snap computes the min and max values in the input data, which is required by Binning.
As you can see, $experience contains min and max values, which are 1 and 22 respectively.
The preview output of the Numeric to Categorical Snap is shown below. This Snap adds one field to the output.
- $level: This field displays categories of employees based on their years of experience.