Skip to content
Advertisement

Tag: units-of-measurement

Pint: How do I define my own units in the Pint Python library?

I am working with Pint to do unit conversions in a Python project. The project involves temperature gradients, which are not defined in Pint. My units are typically “deg.C/km” so I’d like to be able to declare a Quantity as “55 deg.C/km”. I’d then like to use Pint to painlessly convert that Quantity to “XXX deg.F/mile” or “YYY deg.F/km” etc.

How can I manage units in pandas data?

I’m trying to figure out if there is a good way to manage units in my pandas data. For example, I have a DataFrame that looks like this: Currently, the measurement units are encoded in column names. Downsides include: column selection is awkward — df[‘width (m)’] vs. df[‘width’] things will likely break if the units of my source data change

Advertisement