magnitude_in_unit

caqtus.analysis.units.magnitude_in_unit(
series: Series,
unit: Unit | None,
) Series

Return the magnitude of a series in a given unit.

Parameters:
  • series – the series to convert. It should have dtype QuantityDType.

  • unit – the unit to convert to. If None and the series has a not a quantity

  • dtype – unchanged.

  • returned (the series is) – unchanged.

Raises:

ValueError – if the series has a quantity dtype and unit is None.

Returns:

A new series with the same name as the original series, with dtype Float64 and all magnitudes converted to the target unit.