Skip to main content
100%

Gist 0350c21c054d3bc0f23d8ddd8c857ed1

✓ Published0🌍 Public
Aalpha-beta-soup
Last edited May 3, 2016
Created on May 2, 2016

This example shows a reusable Python function that converts lists of numeric values between different units of measurement using the Pint library. It defines `convert`, which takes an array, a source unit, and a target unit, then applies Pint’s `Quantity` constructor and `.to()` method to return a list of converted quantities. The code relies on `pint.UnitRegistry` to access unit definitions, as demonstrated in the docstring where inches are converted to meters. The function is designed for interactive use, such as in IPython, to avoid repeating unit conversion logic.

AI-generated description

Similar vizzes