Standard format specifier
Cloudera Data Visualization implements standard number formatting through Python's format specification mini-language.
The general format of the specifier is:
[[fill]align][sign][symbol][0][width][,][.precision][type]
where:
-
fillis a character other than{or}.The fill works with one of the alignment options. If the alignment character is invalid, both fill and alignment are ignored.
-
alignis one of the following:<forces the field to be left-aligned within the available space; this is the default setting.>forces the field to be right-aligned within available space.=forces padding after the sign, if any, but before the digits; used for printing numeric fields in the form+000000120.^forces the field to be centered within the available space.
-
signis one of the following:+means that a sign must be used for both positive and negative numbers.-means that a sign must be used for negative numbers only; this is the default setting." "(space) means that a leading space must be used on positive numbers, and a minus sign on negative numbers.
-
symbolis one of the following:$, to represent currency#, which is valid only for integers of specific output:0bfor binary,0ofor octal, and0xfor hexadecimal options.
0enables zero-padding.,(comma) signals to use a comma for a thousands separator.-
widthis a decimal integer that defines the minimum field width; if not specified, the content determines the width.If preceded by
0, the field will be zero-padded. This produces the same result as alignment of=and fill of0. -
precisionis a decimal that specifies how many digits to display after the decimal point of a floating point value that is formatted with typef,F, or%, or before and after the decimal point of a floating point value that is formatted with typeg,r, andp.For non-number types, it indicates the maximum fields size, or how many characters to use in field content.
The precision field does not support integer values.
-
typeis one of the following:%is for percentage. Multiplies the number by100, and displays the number in fixed format,f, followed by percent sign.bis for binary format, and outputs numbers in base2.cis for character; it converts integers to corresponding Unicode characters.-
dis for decimal integer; it outputs numbers in base10.Use
Number.toString()method. -
eis for exponent notation for floating point and decimal numbers; it prints the number in scientific notation, usingeto indicate exponent.For example, it would print
345as3.45e2.Use
Number.toExponential()method. -
Eis for exponent notation for floating point and decimal numbers; it prints the number in scientific notation, usingEto indicate exponent.For example, it would print
345as3.45E2.Use
Number.toExponential()method. -
fis for fixed floating point. Displays the number as a fixed-point number.Use
Number.toFixed()method. -
Fis for fixed floating point, same asf; also convertsnantoNAN, andinftoINF. Displays the number as a fixed-point number.Use
Number.toFixed()method. -
gis general format for floating point and decimal values.For a precision
p>=1, it rounds the number topsignificant digits, and formats the result depending on magnitude, either in fixed-point format, or in scientific notation.Both insignificant trailing zeros and decimal point are dropped if unnecessary.
A precision of
0is treated the same as precision of1.Regardless of precision, positive infinity is rendered as
inf, negative infinity as-inf, positive zero as0, negative zero as-0, and NaN asnan.Use
Number.toPrecision()method. -
Gis general format for floating point and decimal values, same asg. Also switches toEnotation if the number is too large. Represents infinity and Nan as uppercase:INF,-INF,NAN.For a precision
p>=1, it rounds the number topsignificant digits, and formats the result depending on magnitude, either in fixed-point format, or in scientific notation.Both insignificant trailing zeros and decimal point are dropped if unnecessary.
A precision of
0is treated the same as precision of1.Regardless of precision, positive infinity is rendered as
inf, negative infinity as-inf, positive zero as0, negative zero as-0, and NaN asnan.Use
Number.toPrecision()method. -
nis general format for floating point and decimal number, same asg. However, it uses current locale settings to insert the appropriate number separator characters.For example, one thousand one hundred and one-tenth would be rendered as
1,100.1in United States and as1.100,1in France. ois for octal format; it outputs numbers in base8.pis rounded percentage; likertype, but multiplied by100and with suffix%.ris rounded toprecisionsignificant digits, padded with zeros whenever necessary, same as forftype. Ifprecisionis not specified, behaves likegtype.-
sis for string format; it is the default type for string, and does not have to be specified.If used for floating point or decimal numbers, it is the metric prefix, SI for the International System of Units. It would render micro (
0.000001or10-6) as1.00μ, and it would render tera (1,000,000,000,000or1012) as1.00T. -
xis for hexadecimal format; it outputs numbers in base16, using lower-case letters for digits over9.afor10,bfor11,cfor12,dfor13,efor14, andffor15. -
Xis for hexadecimal format; it outputs numbers in base16, using upper-case letters for digits over9.Afor10,Bfor11,Cfor12,Dfor13,Efor14, andFfor15. -
None is the same as
sfor strings, anddfor integers. It is similar togfor floating point and decimal values, with at least one digit past the decimal point, and a default precision of12.
