convert_to_unit

caqtus.analysis.units.convert_to_unit(
series: Series,
target_unit: Unit | None,
) Series

Convert a series to a given unit.

Parameters:
  • series – the series to convert. If it has a quantity dtype, target_unit must

  • other (be not be None. If it has any) – dtype, target_unit must be None.

  • target_unit – the unit to convert to.

Returns:

A new series with the same name as the original series. If unit is None, the series is returned unchanged. If the series has a quantity dtype, the series is returned with the same dtype, but all magnitudes converted to the target unit.