format_percent#

format_percent(ratio: float, floating_point: int = 2, scientific_notation_threshold: int = 4, add_positive_prefix: bool = False) str[source]#

Format percent for elegant display.

Parameters
ratiofloat

Ratio to be displayed as percent

floating_point: int , default: 2

Number of floating points to display

scientific_notation_threshold: int, default: 4

Max number of floating points for which to show number as float. If number of floating points is larger than this parameter, scientific notation (e.g. “10E-5%”) will be shown.

add_positive_prefix: bool, default: False

add plus sign before positive percentages (minus sign is always added for negative percentages).

Returns
——-
str

String of ratio as percent