Skip to content

10-minute Quickstart

This quickstart walks through install → model parsing → safe editing → dataset conversion.

1) Install

Follow Install.

2) Parse messy input into a typed model

>>> import omnipy as om
>>> readings = om.Model[list[int]]((101, '102', 103.0))
>>> readings
╭──────────────────╮
Model[list[int]]
                
[101, 102, 103]
╰──────────────────╯

3) Safe interactive manipulation

>>> try:
...     readings.append('invalid')
... except Exception as err:
...     print(type(err).__name__)
>>> readings
ValidationError
╭──────────────────╮
Model[list[int]]
                
[101, 102, 103]
╰──────────────────╯

4) Build a Dataset and batch-parse values

>>> batch = om.Dataset[om.Model[int]]({'sample_a': '1', 'sample_b': 2.0, 'sample_c': 3})
>>> batch
╭───┬────────────────┬────────────┬────────┬──────────────────╮
#Data file name   Type   LengthSize (in memory)
                                               
0sample_aModel[int]-589 Bytes
1sample_bModel[int]-589 Bytes
2sample_cModel[int]-589 Bytes
╰───┴────────────────┴────────────┴────────┴──────────────────╯

5) Convert nested records to pandas-ready tables

>>> records = om.JsonListOfDictsDataset({'rows': [{'id': 'a', 'value': '1'}, {'id': 'b', 'value': 2}]})
>>> records
>>> records_pd = records.to(om.PandasDataset)
>>> records_pd
╭───┬────────────────┬─────────────┬────────┬──────────────────╮
#Data file name   Type    LengthSize (in memory)
                                                
0rowsPandasModel29.5 kB
╰───┴────────────────┴─────────────┴────────┴──────────────────╯

Next steps