Creates a `Dataset` by zipping together the given datasets. This method has similar semantics to the built-in `zip()` function in Python, with the main difference being that the `datasets` argument can be an arbitrary nested structure of `Dataset` objects. For example: ```pytho
(datasets)
| 759 | |
| 760 | @staticmethod |
| 761 | def zip(datasets): |
| 762 | """Creates a `Dataset` by zipping together the given datasets. |
| 763 | |
| 764 | This method has similar semantics to the built-in `zip()` function |
| 765 | in Python, with the main difference being that the `datasets` |
| 766 | argument can be an arbitrary nested structure of `Dataset` objects. |
| 767 | For example: |
| 768 | |
| 769 | ```python |
| 770 | a = Dataset.range(1, 4) # ==> [ 1, 2, 3 ] |
| 771 | b = Dataset.range(4, 7) # ==> [ 4, 5, 6 ] |
| 772 | c = Dataset.range(7, 13).batch(2) # ==> [ [7, 8], [9, 10], [11, 12] ] |
| 773 | d = Dataset.range(13, 15) # ==> [ 13, 14 ] |
| 774 | |
| 775 | # The nested structure of the `datasets` argument determines the |
| 776 | # structure of elements in the resulting dataset. |
| 777 | Dataset.zip((a, b)) # ==> [ (1, 4), (2, 5), (3, 6) ] |
| 778 | Dataset.zip((b, a)) # ==> [ (4, 1), (5, 2), (6, 3) ] |
| 779 | |
| 780 | # The `datasets` argument may contain an arbitrary number of |
| 781 | # datasets. |
| 782 | Dataset.zip((a, b, c)) # ==> [ (1, 4, [7, 8]), |
| 783 | # (2, 5, [9, 10]), |
| 784 | # (3, 6, [11, 12]) ] |
| 785 | |
| 786 | # The number of elements in the resulting dataset is the same as |
| 787 | # the size of the smallest dataset in `datasets`. |
| 788 | Dataset.zip((a, d)) # ==> [ (1, 13), (2, 14) ] |
| 789 | ``` |
| 790 | |
| 791 | Args: |
| 792 | datasets: A nested structure of datasets. |
| 793 | |
| 794 | Returns: |
| 795 | Dataset: A `Dataset`. |
| 796 | """ |
| 797 | return ZipDataset(datasets) |
| 798 | |
| 799 | def concatenate(self, dataset): |
| 800 | """Creates a `Dataset` by concatenating the given dataset with this dataset. |