Skip to content

Mapping over datasets

Maturity labels

  • Now: Stable and supported in current releases.
  • Preview: Usable today, but behavior and APIs may evolve.
  • Planned: Not yet implemented.

Note

Status: Now

Dataset-native mapping with .do(...)

>>> from omnipy import Dataset, Model
>>> xs = Dataset[Model[int]]({'a': '1', 'b': 2.0})
>>> xs.do(lambda x: int(x) + 1).json()

Task mapping with iterate_over_data_files=True

>>> import omnipy as om
>>> from omnipy import Dataset, Model
>>> xs = Dataset[Model[int]]({'a': '1', 'b': 2.0})
>>> @om.TaskTemplate(iterate_over_data_files=True)
... def inc(x: int) -> int:
...     return x + 1
>>> inc.run(xs).json()