Declarative conversions
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
1) What it solves
Teams accumulate ad-hoc conversion glue between JSON-like, row-like, and table-like representations.
2) The idea
Use .to(TargetType) as an explicit conversion boundary. It keeps conversion intent visible and
typed.
3) Example
>>> import omnipy as om
>>> ds = om.JsonListOfDictsDataset({'rows': [{'id': 'a', 'value': '1'}, {'id': 'b', 'value': 2}]})
>>> ds_pd = ds.to(om.PandasDataset)
>>> ds_pd.json()
4) Output / display
╭───┬────────────────┬─────────────┬────────┬──────────────────╮
│ # │ Data file name │ Type │ Length │ Size (in memory) │
│ │ │ │ │ │
│ 0 │ rows │ PandasModel │ 2 │ 9.6 kB │
╰───┴────────────────┴─────────────┴────────┴──────────────────╯
5) When to use / when not
Use it at representation boundaries and in reusable transformation code.
Avoid forcing .to() when no target parser exists yet; add a parse/transform step first.
6) Gotchas
- Convertibility depends on whether the target can parse the source shape.
- Check
.json()before and after conversion when debugging.
7) Links
- How-to: Conversions with
.to() - Feature: Dataset batch hierarchies