# Table.fmt()


Attach a formatting function to a column.


Usage

``` python
Table.fmt(
    column,
    fn,
)
```


## Parameters


`column: str`  
The column to format.

`fn: Callable[[Any], str]`  
A function that takes a single value and returns a string. Missing values (`None`) are rendered as empty cells and are never passed to `fn`.


## Returns


`Table`  
A new table; the original is not modified.


## Examples

Format the `price` column as US dollars:


``` python
from tinytab import Table, fmt_currency

tbl = Table({"item": ["coffee", "bagel"], "price": [3.5, 2.25]})
tbl.fmt("price", fmt_currency)
```


| item   | price  |
|--------|--------|
| coffee | \$3.50 |
| bagel  | \$2.25 |


Any function that takes a value and returns a string works as a formatter:


``` python
tbl.fmt("price", lambda x: f"{x:.1f} USD")
```


| item   | price   |
|--------|---------|
| coffee | 3.5 USD |
| bagel  | 2.2 USD |
