ts_shape.transform.calculator.scaling
Apply a datapoint workbook's linear scaling (opt-in).
A datapoint export can carry scaling_factor and scaling_offset per
datapoint: the engineering value is raw * factor + offset. The library
never applies them on its own, because exports often carry defaults that are
not a real scaling (an offset of 1 on every datapoint, text datapoints
included). :func:apply_scaling applies them when asked to, to numeric
values only, and reports a scaling set on datapoints whose values are text
or bool.
Functions
| Name | Description |
|---|---|
apply_scaling | raw * scaling_factor + scaling_offset for the numeric datapoints. |
apply_scaling
apply_scaling(
dataframe: pd.DataFrame,
metadata: Any,
*,
uuid_column: str = "uuid",
target_column: str = "value_double"
) -> pd.DataFrame
raw * scaling_factor + scaling_offset for the numeric datapoints.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format frame (uuid, value_double / value_integer ...). | required |
metadata | Any | A :class:~ts_shape.MetadataJsonLoader (its :meth:~ts_shape.MetadataJsonLoader.scaling) or a table with uuid, scaling_factor and scaling_offset. | required |
uuid_column | str | The signal column of dataframe. | 'uuid' |
target_column | str | Where the scaled numbers are written (default value_double; integer values become floats there). | 'value_double' |
Returns
| Type | Description |
|---|---|
DataFrame | A copy of dataframe with the scaled values. Rows of datapoints |
DataFrame | without a scaling (factor 1, offset 0), and text / bool values, are |
DataFrame | unchanged. |
Warns
| Type | Description |
|---|---|
DataQualityWarning | When a scaling is set on datapoints whose values are text or bool (an export default, not a scaling; not applied). |