# Using the loaded data

`native` is the object that a dataset’s format library returns, and `df` is a pandas DataFrame. A dataset
has each only where it makes sense.

Each form is read the first time you use it, and kept, so using it again returns the same object.

## Native objects

```ipython3
from nbdemo.data.med import ecg_mitbih_119

record = ecg_mitbih_119.native  # wfdb.Record
record.sig_name, record.fs
```

```myst-ansi
(['MLII', 'V1'], 360)
```

For a SigMF recording, `native` is a small `SigMFRecording` of our own: the metadata, and `read_samples()` for the
samples in the file beside it:

```ipython3
from nbdemo.data.rf import sigmf_synthetic

recording = sigmf_synthetic.native
iq = recording.read_samples()
iq.dtype, len(iq)
```

```myst-ansi
(dtype('complex64'), 1000000)
```

## DataFrames

```ipython3
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 |

The ECG frame has a column for each lead, in physical units, indexed by seconds. The `beat` column holds
the annotation symbol at the sample of each beat. Flight telemetry is indexed by timestamp:

```ipython3
from nbdemo.data.aero import flight_dc

flight_dc.df.iloc[:3, :5]
```

|  | latitude | longitude | altitude | heading | track |
| --- | --- | --- | --- | --- | --- |
| time |  |  |  |  |  |
| 2026-01-01 12:00:00.000+00:00 | 38.8512 | -77.0402 | 5.0 | 10.0 | 0.0 |
| 2026-01-01 12:00:00.100+00:00 | 38.8512 | -77.0402 | 5.0 | 10.0 | 0.0 |
| 2026-01-01 12:00:00.200+00:00 | 38.8512 | -77.0402 | 5.0 | 10.0 | 0.0 |

## When a form is not available

A dataset with no such form raises `FormUnavailable`, which says why and lists the forms it has. The error
is an `AttributeError`, so `hasattr` also tells you:

```ipython3
print(hasattr(sigmf_synthetic, "df"))
print(sigmf_synthetic.forms)

try:
    sigmf_synthetic.df
except AttributeError as error:
    print(error)
```

```myst-ansi
False
('path', 'native')
rf/sigmf_synthetic has no df: the samples are binary IQ data, not a table; use .native, and its read_samples(). Its forms: path, native
```
