Overview of itertools¶
Let us go through one of the important library to manipulate collections called as
- Functions such as
mapare part of core Python libraries.
reduceis part of
- It is not possible to use these functions to perform advanced operations such as grouped aggregations, joins etc.
- Python have several higher level libraries which provide required functionality to perform advanced aggregations such as grouped aggregations, joins etc.
itertoolsis one of the popular library to manipulate collections for such advanced operations.
import itertools as iter
Object `itertools` not found.
Init signature: iter.chain(self, /, *args, **kwargs) Docstring: chain(*iterables) --> chain object Return a chain object whose .__next__() method returns elements from the first iterable until it is exhausted, then elements from the next iterable, until all of the iterables are exhausted. Type: type Subclasses:
l1 = [1, 2, 3, 4] l2 = [4, 5, 6] iter.chain(l1, l2)
<itertools.chain at 0x7fc7c42842e0>
[1, 2, 3, 4, 4, 5, 6]