toolbox/nt/database/iterator.py
def zip(self, *others):
        """
        Creates a `Dataset` by zipping together the given datasets.

        This method has two major differences to the built-in `zip()` function
        in Python. First the zipping happen based on the keys of the
        first dataset (i.e. The first defines the order).

        Second it is assumes that all datasets have the same length and keys.
        (Could be removed, when someone needs it.)

        This function is usually followed by a map call to merge the tuple of
        dicts to a single dict.

        >>> ds1 = ExamplesIterator({'a': {'z': 1}, 'b': {'z': 2}})
        >>> ds1 = ds1.items().map(lambda x: {'example_id': x[0], **x[1]})
        >>> ds2 = ExamplesIterator({'a': {'y': 'c'}, 'b': {'y': 'd', 'z': 3}})
        >>> ds2 = ds2.items().map(lambda x: {'example_id': x[0], **x[1]})
        >>> ds3 = ds1.zip(ds2)
        >>> for e in ds3: print(e)
        ({'example_id': 'a', 'z': 1}, {'example_id': 'a', 'y': 'c'})
        ({'example_id': 'b', 'z': 2}, {'example_id': 'b', 'y': 'd', 'z': 3})

        # Merge the dicts, when conflict, prefer the second
        >>> ds4 = ds3.map(lambda example: {**example[0], **example[1]})
        >>> ds4  # doctest: +ELLIPSIS
                ExamplesIterator(len=2)
                ExamplesIterator(len=2)
              ZipIterator()
            MapIterator(<function <lambda> at 0x...>)
                ExamplesIterator(len=2)
                ExamplesIterator(len=2)
              ZipIterator()
            MapIterator(<function <lambda> at 0x...>)
          ZipIterator()
        MapIterator(<function <lambda> at 0x...>)
        >>> for e in ds4: print(e)
        {'example_id': 'a', 'z': 1, 'y': 'c'}
        {'example_id': 'b', 'z': 3, 'y': 'd'}

        # Lambda that merges an arbitary amount of dicts.
        >>> ds5 = ds3.map(lambda exmaple: dict(sum([list(e.items()) for e in exmaple], [])))
        >>> for e in ds5: print(e)
        {'example_id': 'a', 'z': 1, 'y': 'c'}
        {'example_id': 'b', 'z': 3, 'y': 'd'}

        :param others: list of other iterators to be zipped
        :return: Iterator
        """
        return ZipIterator(self, *others)

        Creates a `Dataset` by zipping together the given datasets.

        This method has two major differences to the built-in `zip()` function
        in Python. First the zipping happen based on the keys of the
        first dataset (i.e. The first defines the order).

        Second it is assumes that all datasets have the same length and keys.
        (Could be removed, when someone needs it.)

        This function is usually followed by a map call to merge the tuple of
        dicts to a single dict.

        >>> ds1 = ExamplesIterator({'a': {'z': 1}, 'b': {'z': 2}})
        >>> ds1 = ds1.items().map(lambda x: {'example_id': x[0], **x[1]})
        >>> ds2 = ExamplesIterator({'a': {'y': 'c'}, 'b': {'y': 'd', 'z': 3}})
        >>> ds2 = ds2.items().map(lambda x: {'example_id': x[0], **x[1]})
        >>> ds3 = ds1.zip(ds2)
        >>> for e in ds3: print(e)
        ({'example_id': 'a', 'z': 1}, {'example_id': 'a', 'y': 'c'})
        ({'example_id': 'b', 'z': 2}, {'example_id': 'b', 'y': 'd', 'z': 3})

        # Merge the dicts, when conflict, prefer the second
        >>> ds4 = ds3.map(lambda example: {**example[0], **example[1]})
        >>> ds4  # doctest: +ELLIPSIS
                ExamplesIterator(len=2)
                ExamplesIterator(len=2)
              ZipIterator()
            MapIterator(<function <lambda> at 0x...>)
                ExamplesIterator(len=2)
                ExamplesIterator(len=2)
              ZipIterator()
            MapIterator(<function <lambda> at 0x...>)
          ZipIterator()
        MapIterator(<function <lambda> at 0x...>)
        >>> for e in ds4: print(e)
        {'example_id': 'a', 'z': 1, 'y': 'c'}
        {'example_id': 'b', 'z': 3, 'y': 'd'}

        # Lambda that merges an arbitary amount of dicts.
        >>> ds5 = ds3.map(lambda exmaple: dict(sum([list(e.items()) for e in exmaple], [])))
        >>> for e in ds5: print(e)
        {'example_id': 'a', 'z': 1, 'y': 'c'}
        {'example_id': 'b', 'z': 3, 'y': 'd'}

        :param others: list of other iterators to be zipped
        :return: Iterator
        
Creates a `Dataset` by zipping together the given datasets.
This method has two major differences to the built-in `zip()` function
in Python. First the zipping happen based on the keys of the
first dataset .

Second it is assumes that all datasets have the same length and keys.
(Could be removed, when someone needs it.)

This function is usually followed by a map call to merge the tuple of
dicts to a single dict.





Lambda that merges an arbitary amount of dicts.
Creates a ` Dataset ` by zipping together the given datasets . This method has two major differences to the built - in ` zip () ` function in Python . First the zipping happen based on the keys of the first dataset . Second it is assumes that all datasets have the same length and keys . ( Could be removed when someone needs it . ) This function is usually followed by a map call to merge the tuple of dicts to a single dict . Lambda that merges an arbitary amount of dicts .
def zip(self, *others):
        return ZipIterator(self, *others)
def zip ( self , * others ) : return ZipIterator ( self , * others )
Creates a `Dataset` by zipping together the given datasets.
Creates a ` Dataset ` by zipping together the given datasets .
"""
        Creates a `Dataset` by zipping together the given datasets.

        This method has two major differences to the built-in `zip()` function
        in Python. First the zipping happen based on the keys of the
        first dataset (i.e. The first defines the order).

        Second it is assumes that all datasets have the same length and keys.
        (Could be removed, when someone needs it.)

        This function is usually followed by a map call to merge the tuple of
        dicts to a single dict.

        >>> ds1 = ExamplesIterator({'a': {'z': 1}, 'b': {'z': 2}})
        >>> ds1 = ds1.items().map(lambda x: {'example_id': x[0], **x[1]})
        >>> ds2 = ExamplesIterator({'a': {'y': 'c'}, 'b': {'y': 'd', 'z': 3}})
        >>> ds2 = ds2.items().map(lambda x: {'example_id': x[0], **x[1]})
        >>> ds3 = ds1.zip(ds2)
        >>> for e in ds3: print(e)
        ({'example_id': 'a', 'z': 1}, {'example_id': 'a', 'y': 'c'})
        ({'example_id': 'b', 'z': 2}, {'example_id': 'b', 'y': 'd', 'z': 3})

        # Merge the dicts, when conflict, prefer the second
        >>> ds4 = ds3.map(lambda example: {**example[0], **example[1]})
        >>> ds4  # doctest: +ELLIPSIS
                ExamplesIterator(len=2)
                ExamplesIterator(len=2)
              ZipIterator()
            MapIterator(<function <lambda> at 0x...>)
                ExamplesIterator(len=2)
                ExamplesIterator(len=2)
              ZipIterator()
            MapIterator(<function <lambda> at 0x...>)
          ZipIterator()
        MapIterator(<function <lambda> at 0x...>)
        >>> for e in ds4: print(e)
        {'example_id': 'a', 'z': 1, 'y': 'c'}
        {'example_id': 'b', 'z': 3, 'y': 'd'}

        # Lambda that merges an arbitary amount of dicts.
        >>> ds5 = ds3.map(lambda exmaple: dict(sum([list(e.items()) for e in exmaple], [])))
        >>> for e in ds5: print(e)
        {'example_id': 'a', 'z': 1, 'y': 'c'}
        {'example_id': 'b', 'z': 3, 'y': 'd'}

        :param others: list of other iterators to be zipped
        :return: Iterator
        """
None
self
others
list of other iterators to be zipped
list of other iterators to be zipped