engineering-notation
raw JSON → 0.13.2 verified Fri May 01 auth: no python
Python library for converting floats to human-readable engineering notation strings (e.g., 1.5k, 3.3M, 47n). Version 0.13.2, requires Python >=3.12. Maintained actively.
pip install engineering-notation Common errors
error ModuleNotFoundError: No module named 'engineering_notation' ↓
cause The package is not installed or the import name is incorrect (using hyphen instead of underscore).
fix
pip install engineering-notation ; then import from engineering_notation (underscore).
error AttributeError: module 'engineering_notation' has no attribute 'EngrNumber' ↓
cause Common mistake: import engineering_notation as en and then use en.EngrNumber. The correct import is from engineering_notation import EngrNumber.
fix
Change import to: from engineering_notation import EngrNumber
Warnings
breaking Python 3.12+ is required. Older Python versions (3.11 and below) are not supported. ↓
fix Upgrade Python to 3.12 or later.
gotcha EngrNumber('10') returns 10 with no prefix (plain number). For values exactly on a power-of-1000 boundary, the prefix might be omitted unless you specify significant digits. ↓
fix Use EngrNumber('10', sig_digits=2) to ensure a prefix like 10.0 (still no prefix) or 10.0e0. For true engineering notation, values < 1000 may not get a prefix.
Imports
- EngrNumber wrong
import engineering_notation as encorrectfrom engineering_notation import EngrNumber
Quickstart
from engineering_notation import EngrNumber
print(EngrNumber(1500)) # Output: 1.5k
print(EngrNumber(3.3e6)) # Output: 3.3M
print(EngrNumber(47e-9)) # Output: 47n