hgrecco / pint-pandas

Pandas support for pint
Other
166 stars 41 forks source link

ito_base_units doesn't work #163

Closed mangecoeur closed 11 months ago

mangecoeur commented 1 year ago

It seems ito_base_units isn't working, with the following example doing meters times millimeters then ito_base_units reduces to m2 for scalars but not for pint-pandas columns.

o = (3 * ureg('millimeters')) * (4 *ureg('meters'))
#12 meter millimeter

o.ito_base_units()
# 0.012 meter2
df = pd.DataFrame({
     "width": pd.Series([1, 2.0, 2, 3.0], dtype="pint[millimeters]"),
     "length": pd.Series([1, 2, 2.0, 3], dtype="pint[meters]"),
})
area = df.width * df.length
# dtype: pint[meter * millimeter]

area.pint.ito_base_units()
# dtype: pint[meter * millimeter]
andrewgsavage commented 11 months ago

Thanks, I removed the ito_ for the time being as they're not doing what's expected.