Formatting

Formatting Basics

Format the currency values to make them look better.

gt_tbl_5 = (
    gt_tbl_4
    .fmt_currency(
        columns=["revenue_dollars", "profit_dollars"],
        use_subunits=False
    )
)

gt_tbl_5
Sales of Coffee Equipment
Product Revenue Profit
Amount Percent Amount Percent
Grinder $904,500 0.03 $567,960 0.04
Moka pot $2,045,250 0.07 $181,080 0.01
Cold brew $288,750 0.01 $241,770 0.02
Filter $404,250 0.01 $70,010 0.0
Drip machine $2,632,000 0.09 $1,374,450 0.09
AeroPress $2,601,500 0.09 $1,293,780 0.09
Pour over $846,000 0.03 $364,530 0.02
French press $1,113,250 0.04 $748,120 0.05
Cezve $2,512,500 0.09 $1,969,520 0.13
Chemex $3,137,250 0.11 $817,680 0.06
Scale $3,801,000 0.13 $2,910,290 0.2
Kettle $756,250 0.03 $617,520 0.04
Espresso Machine $8,406,000 0.29 $3,636,440 0.25
Total $29,448,500 1.0 $14,793,150 1.0

Format the fractional values by turning them into percentages.

gt_tbl_6 = (
    gt_tbl_5
    .fmt_percent(
        columns=["revenue_pct", "profit_pct"],
        decimals=0
    )
)

gt_tbl_6
Sales of Coffee Equipment
Product Revenue Profit
Amount Percent Amount Percent
Grinder $904,500 3% $567,960 4%
Moka pot $2,045,250 7% $181,080 1%
Cold brew $288,750 1% $241,770 2%
Filter $404,250 1% $70,010 0%
Drip machine $2,632,000 9% $1,374,450 9%
AeroPress $2,601,500 9% $1,293,780 9%
Pour over $846,000 3% $364,530 2%
French press $1,113,250 4% $748,120 5%
Cezve $2,512,500 9% $1,969,520 13%
Chemex $3,137,250 11% $817,680 6%
Scale $3,801,000 13% $2,910,290 20%
Kettle $756,250 3% $617,520 4%
Espresso Machine $8,406,000 29% $3,636,440 25%
Total $29,448,500 100% $14,793,150 100%