11.3 Using the toolz package
The toolz
package comprises functions that are similar to some of the functions in the built-in itertools
and functools
modules. The toolz
package adds some functions to perform sophisticated processing on dictionary objects. This package has a narrow focus on iterables, dictionaries, and functions. This overlaps nicely with the data structures available in JSON and CSV documents. The idea of processing iterables that come from files or databases allows a Python program to deal with vast amounts of data without the complication of filling memory with the entire collection of objects.
We’ll look at a few example functions from the various subsections of the toolz
package. There are over sixty individual functions in the current release. Additionally, there is a cytoolz
implementation written in Cython that provides higher performance than the pure Python toolz
package.
11.3.1 Some itertoolz functions
We’ll look at a common data analysis problem...