...

/

Actions (II): Reduce and Aggregate Functions: Max, Min, and Mean

Actions (II): Reduce and Aggregate Functions: Max, Min, and Mean

Learn how to use another set of basic and useful Actions.

If the actions in this lesson have anything in common, it’s that they all merge values while performing calculations on rows.

Let’s start by looking at the reduce action.

Reduce

Reduce combines elements to produce an aggregated result based on a function provided. This combination is done at the column level. The following diagram helps to illustrate this.

In this lesson’s project we’re working with a dataset in CSV format with data on farm stands sales, on a yearly basis, for the city of Austin, TX. The codebase is included in the following project’s widget:

mvn install exec:exec
Project showcasing aggregated functions

However, we have to include an option to infer schema. This saves us from doing excessive parsing if the numeric fields are retrieved initially as String values.

Here is the code for doing this:

        //Ingest data from CSV file
...