concept length in category data

appears as: length, length, lengths
Mastering Large Datasets with Python: Parallelize and Distribute Your Python Code

This is an excerpt from Manning's book Mastering Large Datasets with Python: Parallelize and Distribute Your Python Code.

To find a simple average, we want to take the sum of the values and divide it by the number of values that we’re summing. To find the sum, we can use Python’s built-in sum function on the tweets. To find the number of tweets, we can find the length of the list with the len function. With those two values ready, we can calculate the average by dividing the sum by the length.

The filter function starts with a sequence of some sort, so we know that it’s a good candidate for reduction on that ground. Our output data in this instance is going to be a list of a length equal to or less than that of our previous sequence. For example, if we have a sequence where all the numbers are 2 (an even number), then our reduction should return the same sequence as a list. In contrast, if all the numbers are odd, our reduction should return an empty list.