Skip to main content
Version: 0.0.98

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
NameDescription
apply_scalingraw * scaling_factor + scaling_offset for the numeric datapoints.

apply_scaling​

functionsource
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
NameTypeDescriptionDefault
dataframeDataFrameLong-format frame (uuid, value_double / value_integer ...).required
metadataAnyA :class:~ts_shape.MetadataJsonLoader (its :meth:~ts_shape.MetadataJsonLoader.scaling) or a table with uuid, scaling_factor and scaling_offset.required
uuid_columnstrThe signal column of dataframe.'uuid'
target_columnstrWhere the scaled numbers are written (default value_double; integer values become floats there).'value_double'
Returns
TypeDescription
DataFrameA copy of dataframe with the scaled values. Rows of datapoints
DataFramewithout a scaling (factor 1, offset 0), and text / bool values, are
DataFrameunchanged.
Warns
TypeDescription
DataQualityWarningWhen a scaling is set on datapoints whose values are text or bool (an export default, not a scaling; not applied).