All Projects → azaitsev → millify

azaitsev / millify

Licence: MIT license
Convert long numbers into a human-readable format in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to millify

numerify
number format tool.
Stars: ✭ 57 (-10.94%)
Mutual labels:  number-formatter
nepali utils
A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Numbers, Nepali Unicode, Nepali Moments and many more.
Stars: ✭ 22 (-65.62%)
Mutual labels:  number-formatter
number-to-words
convert number into words (english, french, italian, roman, spanish, portuguese, belgium, dutch, swedish, polish, russian, iranian, roman, aegean)
Stars: ✭ 53 (-17.19%)
Mutual labels:  numbers-to-text
millify
Convert long numbers to pretty, human-readable strings
Stars: ✭ 119 (+85.94%)
Mutual labels:  human-readable

millify

Convert long numbers into a human-readable format in Python

Installation

pip install millify

Usage

Convert to number with binary prefix

from millify import millify

millify(1234)
# '1k'

millify('1234') # same for strings
# '1k'

millify(12345678)
# '12M'

millify(12345678, precision=2)
# '12.35M'

millify(10000, precision=2) # hide nulls in decimals by default
# '10k'

millify(10000, precision=2, drop_nulls=False)
# '10.00k'

prefixes = ['kB', 'MB', 'GB']
millify(10000, prefixes=prefixes)
# '10kB'

Add a thousands separator

from millify import prettify

prettify(1234)
# '1,234'

prettify('1234') # same for strings
# '1,234'

prettify(1234, '`')
# '1`234'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].