Open
Description
I was modelling emissions, where the unit is kg/kg, meaning kg(CO2)/kg(product).
In this context, I found the following strange behaviour:
import pandas as pd, pint_pandas
s = pd.Series([1, 2, 3], dtype='pint[kg/kg]')
print(f"{s.mean() = }") # <Quantity(2.0, 'dimensionless')>
print(f"{s.describe()['mean'] = }") # np.float64(2.0)
print(f"{s.pint.to('g/kg').mean() = }") # <Quantity(2000.0, 'gram / kilogram')>
print(f"{s.pint.to('g/kg').describe()['mean'] = }") # np.float64(2.0)
The .mean()
method reflects the unit change, but .describe()
does not.
I assume this is because .mean()
is generally unit aware, while .describe()
is not and works only because the actual unit is dimensionless
, but then I would prefer if it did not work at all, rather than returning a wrong answer.
Metadata
Metadata
Assignees
Labels
No labels