File size: 524 Bytes
6bef416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations

import pandas as pd


def fmt_pct(value: float) -> str:
    if pd.isna(value):
        return "n/a"
    return f"{float(value):.1%}"


def fmt_money(value: float) -> str:
    if pd.isna(value):
        return "n/a"
    return f"${float(value):.4f}"


def fmt_int(value: float | int) -> str:
    if pd.isna(value):
        return "n/a"
    return f"{int(value):,}"


def fmt_latency_ms(value: float) -> str:
    if pd.isna(value):
        return "n/a"
    return f"{float(value):,.0f} ms"