INNER CODE UNIT · Python
as_unit
HHammond/PrettyPandas · prettypandas/formatters.py:57
def as_unit(unit, precision=2, location='suffix'):
"""Convert value to unit.
Parameters:
-----------
:param v: numerical value
:param unit: string of unit
:param precision: int
decimal places to round to
:param location:
'prefix' or 'suffix' representing where the currency symbol falls
relative to the value
"""
if not isinstance(precision, Integral):
raise TypeError("Precision must be an integer.")
if location == 'prefix':
formatter = partial(_format_numer, prefix=unit)