{ "info": { "author": "Stijn Debrouwere", "author_email": "stijn@debrouwere.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: ISC License (ISCL)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Utilities" ], "description": "Ballpark\n========\n\nWhen people think of human-readable numbers, they think of rounding to\ntwo decimal places and adding a thousands separator. 12,214.17 is\nalready quite an improvement over 12214.16666667. But standard formats\nfor human-readable numbers still have various flaws:\n\n- even with a thousands separator, at a glance you might easily mistake\n a billion for a trillion\n- even when rounding, an amount like 12,214.17 dollars is a lot of\n number noise for communicating 12.2K\n- scientific notation leads to exponents like ``1.22e4`` which are hard\n to interpret because we're used to working with thousands, millions\n and billions \u2013 orders of magnitudes that are multiples of three\n- when comparing multiple measurements of the same underlying variable,\n like the yearly sales numbers for 2010-2015, it's annoying to have\n some numbers in thousands and other numbers in millions \u2013 you want\n consistency so that digits in the same position are of the same\n magnitude\n\n``python-ballpark`` introduces *business notation*, an offshoot of\n`engineering\nnotation `__, for\nproducing better human-readable numbers.\n\nInstall with ``pip install ballpark`` or ``pip3 install ballpark``.\n\nWhat it looks like\n~~~~~~~~~~~~~~~~~~\n\n+---------------------+-----------------------+-----------------+-----------------+\n| numbers | rounded | engineering | **business |\n| | | notation | notation** |\n+=====================+=======================+=================+=================+\n| 11234.22, | 11,234.22, | 11.2E+3, | 11K, 233K, |\n| 233000.55, | 233,000.55, | 233E+3, 1.18E+6 | 1,180K |\n| 1175125.2 | 1,175,125.2 | | |\n+---------------------+-----------------------+-----------------+-----------------+\n| 111, 1111.23, | 111, 1,111.23, | 111, 1.11E+3, | 0.11K, 1.11K, |\n| 1175125.234 | 1,175,125.23 | 1.18E+6 | 1,180.00K |\n+---------------------+-----------------------+-----------------+-----------------+\n\nHow to use it\n~~~~~~~~~~~~~\n\n.. code:: python\n\n >>> from ballpark import human, scientific, engineering, business, ballpark\n >>> business([11234.22, 233000.55, 1175125.2])\n ['11K', '233K', '1,180K']\n >>>\n >>> # business notation is also aliased as `ballpark`\n >>> ballpark([11234.22, 233000.55, 1175125.2])\n ['11K', '233K', '1,180K']\n >>>\n >>> # or use the shortcut functions\n >>> from ballpark import H, S, E, B\n >>> B([11234.22, 233000.55, 1175125.2])\n ['11K', '233K', '1,180K']\n >>>\n >>> # all notations accept single numbers too, but then we can't guarantee\n >>> # that all numbers will have the same prefix (kilo, mega etc.)\n >>> [B(value) for value in [11234.22, 233000.55, 1175125.2]]\n ['11.2K', '233K', '1.18M']\n\nHow it works\n~~~~~~~~~~~~\n\n.. code:: python\n\n business(values, precision=3, prefix=True, prefixes=SI, statistic=median)\n\n- **precision:** the amount of significant digits. When necessary,\n ``business`` will round beyond the decimal sign as well: in the\n example above, ``1175125.2`` was turned into ``1,180K`` rather than\n ``1,175K`` to retain only 3 significant digits.\n- **prefix:** whether to use SI prefixes like m (milli), K (kilo) and\n so on instead of scientific exponents like E+03.\n- **prefixes:** a mapping of orders of magnitude to prefixes, e.g.\n ``{-3: 'm', 3: 'K'}``, allowing you to customize the prefixes, for\n example using B for billion instead of T for tera.\n- **statistic:** a function to produce the reference number. The\n reference number determines the order of magnitude and precision for\n the entire group of numbers, so that for example when the reference\n number is 23.3K, smaller numbers like 1.1K won't gain a decimal place\n and larger numbers like 1,180K won't jump an order of magnitude to\n 1.18M. The median often works well, but if you want more precision\n for small outliers, try ``ballpark.statistics.Q1`` or even Python's\n builtin ``min``.\n", "description_content_type": null, "docs_url": null, "download_url": "https://www.github.com/debrouwere/python-ballpark/tarball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/debrouwere/python-ballpark/", "keywords": "human numbers format notation scientific engineering", "license": "ISC", "maintainer": "", "maintainer_email": "", "name": "ballpark", "package_url": "https://pypi.org/project/ballpark/", "platform": "", "project_url": "https://pypi.org/project/ballpark/", "project_urls": { "Download": "https://www.github.com/debrouwere/python-ballpark/tarball/master", "Homepage": "https://github.com/debrouwere/python-ballpark/" }, "release_url": "https://pypi.org/project/ballpark/1.4.0/", "requires_dist": null, "requires_python": "", "summary": "Better human-readable numbers.", "version": "1.4.0" }, "last_serial": 2803881, "releases": { "1.1.1": [ { "comment_text": "", "digests": { "md5": "e4de6ff2f5b6697accafecc9d94630e1", "sha256": "4fc4df41ea0f20f506d6648bc38d98e52e5972f28757d0bc87f20074493b7b88" }, "downloads": -1, "filename": "ballpark-1.1.1.tar.gz", "has_sig": false, "md5_digest": "e4de6ff2f5b6697accafecc9d94630e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5219, "upload_time": "2016-02-08T07:56:04", "url": "https://files.pythonhosted.org/packages/35/5f/beb2d98e273cf9f70302f1771feafcd350416c30726653a6b27ebae37010/ballpark-1.1.1.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "c21f96e8a22ce74a0dea2bcd198ca366", "sha256": "fccdb9abf5d97e79bc07bc70cdfe2edd89726e087d883f9fd7d02dbea19fb3f2" }, "downloads": -1, "filename": "ballpark-1.3.0.tar.gz", "has_sig": false, "md5_digest": "c21f96e8a22ce74a0dea2bcd198ca366", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5793, "upload_time": "2017-04-06T08:54:02", "url": "https://files.pythonhosted.org/packages/2e/cc/2da7f7e371bf690b3bcfe82b7fc7ff72227548db72c47919e7a91ba3801b/ballpark-1.3.0.tar.gz" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "02ba48e7660a53a6edf22f5bb87848f9", "sha256": "a5b46cf65f16d15d6969d3aa9c4f6172b752c80eeac2add6eb06b4824c89558d" }, "downloads": -1, "filename": "ballpark-1.4.0.tar.gz", "has_sig": false, "md5_digest": "02ba48e7660a53a6edf22f5bb87848f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6516, "upload_time": "2017-04-14T13:56:53", "url": "https://files.pythonhosted.org/packages/8f/5b/e259db671525c63202885c2cad5fc90cf095a65149a2ad3a7586fa73180f/ballpark-1.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "02ba48e7660a53a6edf22f5bb87848f9", "sha256": "a5b46cf65f16d15d6969d3aa9c4f6172b752c80eeac2add6eb06b4824c89558d" }, "downloads": -1, "filename": "ballpark-1.4.0.tar.gz", "has_sig": false, "md5_digest": "02ba48e7660a53a6edf22f5bb87848f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6516, "upload_time": "2017-04-14T13:56:53", "url": "https://files.pythonhosted.org/packages/8f/5b/e259db671525c63202885c2cad5fc90cf095a65149a2ad3a7586fa73180f/ballpark-1.4.0.tar.gz" } ] }