Sample data#

nbdemo.data holds sample datasets for Nominal’s open-source projects, grouped by domain: aero, med and rf.

Each dataset is a Dataset with up to three ways to be accessed:

  • as a file path, with path

  • as its format’s own Python object, with native

  • as a pandas DataFrame, with df

Usage#

Import a dataset from its domain: aero, med or rf. Importing reads only a small manifest; nothing is downloaded or parsed until you use the dataset.

As Path#

from nbdemo.data.med import ecg_mitbih_119

ecg_mitbih_119.path  # a Path, to pass to your own loader
PosixPath('/home/runner/work/nbdemo/nbdemo/src/nbdemo/data/med/ecg_mitbih_119/119.hea')

The same dataset as the Python object that its format’s library returns, and as a DataFrame. A dataset has each only where it makes sense; see forms.

As Native#

ecg_mitbih_119.native  # a wfdb.Record
<wfdb.io.record.Record at 0x7f846ee7c590>

As Dataframe#

ecg_mitbih_119.df.head()
MLII V1 beat
time
0.000000 -0.995 -0.47 NaN
0.002778 -0.995 -0.47 NaN
0.005556 -0.995 -0.47 NaN
0.008333 -0.995 -0.47 NaN
0.011111 -0.995 -0.47 NaN

To work with the domains as a group, import the package under a short name. catalog() lists the datasets, and get() looks one up by id:

import nbdemo.data as nd

nd.catalog("rf")
[Dataset('rf/sigmf_synthetic', 8.00 MB, local, forms=('path', 'native'))]

Install the package with the extras for the formats you read. Using the paths covers testing a file loader, and Using the loaded data covers native and df, including FormUnavailable, which a dataset raises for a form it does not have. The catalog lists every dataset, and Adding a dataset explains how to contribute one. The API is the full reference.