diff --git a/pipelib/core.py b/pipelib/core.py
index 7fbce5b..a55b986 100644
--- a/pipelib/core.py
+++ b/pipelib/core.py
@@ -1,7 +1,8 @@
 import random
 import pickle
 from pathlib import Path
-from itertools import chain, islice
+from itertools import chain, islice, tee
+from collections import deque
 
 import pipelib
 
@@ -39,6 +40,12 @@ class Dataset:
                 yield from chunk
         return PipelinedDataset(self, f)
 
+    def window(self, window_size):
+        def f(dataset):
+            yield from zip(*(deque(islice(it, i), 0) or it
+                           for i, it in enumerate(tee(dataset, window_size))))
+        return PipelinedDataset(self, f)
+
     def map(self, map_func):
         def f(dataset):
             return map(map_func, dataset)

Add Dataset.window method
[FYI](https://github.com/pytoolz/toolz/blob/master/toolz/itertoolz.py#L662)
diff --git a/tests/test_core.py b/tests/test_core.py
index a9cc5e1..92f5e58 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -60,6 +60,16 @@ class DatasetTestCase(TestCase):
         self.check_for_loop(chain.from_iterable(data), self.base)
         self.check_correct_pipelined_dataset(data, self.base, nested=False)
 
+    def test_window(self):
+        window_size = 3
+        data = self.data.window(window_size)
+        for x in data:
+            self.assertEqual(len(x), window_size)
+
+        expected = zip(*(self.base[i:] for i in range(window_size)))
+        self.check_for_loop(data, expected)
+        self.check_correct_pipelined_dataset(data, self.base, nested=False)
+
     def test_map(self):
         def f(x):
             return x ** 2

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
cloudpickle==2.2.1
exceptiongroup==1.2.2
importlib-metadata==6.7.0
iniconfig==2.0.0
packaging==24.0
-e git+https://github.com/yasufumy/pipelib.git@0e57202c37e8e4aaab87021f17c7744f36514b5f#egg=pipelib
pluggy==1.2.0
pytest==7.4.4
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: pipelib
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cloudpickle==2.2.1
      - exceptiongroup==1.2.2
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/pipelib

tests/test_core.py::DatasetTestCase::test_window
tests/test_core.py::DatasetTestCase::test_all tests/test_core.py::DatasetTestCase::test_apply tests/test_core.py::DatasetTestCase::test_batch tests/test_core.py::DatasetTestCase::test_concat tests/test_core.py::DatasetTestCase::test_filter tests/test_core.py::DatasetTestCase::test_first tests/test_core.py::DatasetTestCase::test_flat_map tests/test_core.py::DatasetTestCase::test_load tests/test_core.py::DatasetTestCase::test_map tests/test_core.py::DatasetTestCase::test_method_chain tests/test_core.py::DatasetTestCase::test_repeat tests/test_core.py::DatasetTestCase::test_save tests/test_core.py::DatasetTestCase::test_shuffle tests/test_core.py::DatasetTestCase::test_take tests/test_core.py::DatasetTestCase::test_zip tests/test_core.py::TextDatasetTestCase::test_text tests/test_core.py::DirDatasetTestCase::test_directory
pipelib/core.py
pipelib/core.py