# Measurements Example URL: /examples/measurements The upstream measurements.py example explained — string and numeric measurements, inline kwargs declaration, validators, units, a multi-dimensional power time series converted to a pandas DataFrame, and marginal limits. Every way to declare and set a measurement, in one script. Based on `examples/measurements.py`. Needs `pip install pandas` (or `openhtf[examples]`) for the DataFrame step. The run fails because `inline_kwargs` is 15 against a 0–10 limit, and is flagged marginal because `resistance` = 13 sits between the marginal maximum (11) and the hard maximum (17). `htf.Measurement('name')` objects, bare strings, and `name + kwargs`. Mixing objects and strings in one decorator works but upstream recommends one style per decorator. Measurements → `test.measurements.x = ...` and `test.measurements['x'] = ...` are equivalent; the index form allows loops and computed names. `validators.in_range(0, 10)` is the object behind `.in_range(0, 10)`. Use it directly for the kwargs form or for `dimension_pivot_validate`. Validators reference → Dimensions accept unit strings, `UnitDescriptor`s or `htf.Dimension(...)`. The stored value here is a dummy `0`; the axes carry the data — a common trick for a table of samples. `DimensionedMeasuredValue.to_dataframe()` builds a pandas DataFrame with one column per dimension plus the value. Later phases can compute aggregates from it. Multi-dimensional → Inner limits that mark a passing value as marginal at measurement, phase and test level — visible in the record's `marginal` flags and in the console banner. Marginal → Measurement names must be valid Python identifiers (after `with_args` substitution) because they are attributes of `test.measurements`. A name may be declared once per phase. Declaring it on several phases is allowed but makes flattened exports ambiguous. Setting a measurement twice is discouraged; the framework may enforce single assignment in a future release.