Pint defines and manipulates physical quantities in Python, combining numbers with units for arithmetic and conversion. It ships with a broad built-in unit registry and optional NumPy, pandas, and uncertainties integration.
Overview
Pint lets Python code treat measurements as values paired with units: you add, subtract, multiply, and convert quantities without manual factor tracking. A UnitRegistry loads definitions from an editable text file, recognizing prefixed and pluralized unit names when base units are defined.
The package includes physical units, prefixes, and constants out of the box, and you can extend or replace definitions without changing library code. Conversions cover ordinary dimensions and non-multiplicative units such as absolute temperature offsets. Quantities can wrap floats, decimals, fractions, or NumPy arrays; NumPy ufuncs respect dimensions when arrays are used.
Formatting supports PEP 3101-style quantity strings with optional symbolic, LaTeX, or pretty output when Babel is present. A pint-convert command-line script converts between units or prints conversion factors. The pint-pandas extension adds unit-aware pandas columns and DataFrame operations.
Pint runs on modern Python with minimal core dependencies and interacts with NumPy, uncertainties, and pandas only when those packages are installed. It is maintained as a community scientific utility for engineering and research scripts.
Key features
- UnitRegistry quantity arithmetic
- Editable unit definition files
- Prefix and plural unit parsing
- NumPy-aware operations
- Temperature offset conversions
- pint-convert CLI converter
- pandas extension types
- uncertainties package support
Use cases
- Scientific calculation with units
- Safe unit conversion in scripts
- NumPy arrays with dimensions
- pandas columns with physical units