*Takes a json object, and considers each field to be a separate datapoint’s data.
It then hijacks its argument, and performs the given transform on all of the fields, returning the result.*

`reduce`

performs a given transform on all the elements of a multi-element datapoint.

Suppose you have the following data:

```
[
{
"a": 3,
"b": 5
},
{
"q": 10,
"z": 23
}
]
```

Then the transform `reduce(sum)`

will give you:

```
[8,33]
```

Reduce took each element in the given datapoint, and applied the transform `sum`

to it.

The reduce transform is particularly useful in conjunction with the `map`

transform.

Suppose you want to find the average number of steps taken every weekday.

Running the following transform will give you a map of weekday to average step count:

```
while(day==next:day,sum) | map(weekday, mean)
```

For example, a possible result of the above transform could be:

```
[
{
"Monday": 12243,
"Tuesday": 13452,
"Wednesday": 14523,
"Thursday": 9543,
"Friday": 20487,
"Saturday": 3000,
"Sunday": 4000
}
]
```

You can now find the average per weekday by running `reduce(mean)`

, giving a final transform:

```
while(day==next:day,sum) | map(weekday, mean) | reduce(mean)
```

One-To-One | Stateless | Peek | Input Schema | Output Schema |
---|---|---|---|---|

True | False | False |

# | Description | Optional | Constant | Hijacked | Default |
---|---|---|---|---|---|

1 | The script to instantiate to perform on all elements of input | False | False | True |