Chapter 5. Accumulation operations with reduce
This chapter covers
- Recognizing the reduce pattern for N-to-X data transformations
- Writing helper functions for reductions
- Writing lambda functions for simple reductions
- Using reduce to summarize data
In chapter 2, we learned about the first part of the map and reduce style of programming: map. In this chapter, we introduce the second part: reduce. As we noted in chapter 2, map performs N-to-N transformations. That is, if we have a situation where we want to take a sequence and get a same-sized sequence back, map is our go-to function. Among the examples of this that we’ve reviewed are file processing (we have a list of files and we want to do something to all of them; discussed in chapter ...
Get Mastering Large Datasets with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.