finam.data.to_units#
- finam.data.to_units(xdata, units, check_equivalent=False, report_conversion=False)[source]#
Convert data to given units.
- Parameters:
xdata (pint.Quantity) – The given data array.
units (str or pint.Unit) – Desired units.
check_equivalent (bool, optional) – Checks for equivalent units and simply re-assigns if possible.
report_conversion (bool, optional) – If true, returns a tuple with the second element indicating the unit conversion if it was required.
- Returns:
The converted data.
If
report_conversion
isTrue
, a tuple is returned with the second element indicating the unit conversion if it was required.The second element is
None
if no conversion was required, and a tuple of twopint.Unit
objects otherwise.- Return type:
pint.Quantity or tuple(pint.Quantity, tuple(pint.Unit, pint.Unit) or None)