Custom formatter for a DataFrame column?


Is there a good way to customize the formatting of the values in particular columns of a DataFrame? I have a column that is using the types from Currencies.jl, which have great functionality but their default display format isn’t what I’d like to see in the table:

julia> using Currencies
julia> @usingcurrencies USD, CAD
julia> df = DataFrame(name=["401k", "RRSP"], balance=[1500000USD, 200000CAD])
2×2 DataFrames.DataFrame
│ Row │ name   │ balance     │
│ 1   │ "401k" │ 1.5e6USD    │
│ 2   │ "RRSP" │ 200000.0CAD │

julia> format(1500000CAD, styles=[:us])
"CAD 1,500,000.00"

Note that I’m using DataFrames 0.10.1, but I also looked at the 0.11 documentation and didn’t see anything that looks applicable to this.


Data frames use the standard show methods to represent values, so the only solution is to override that. It would make sense to improve this by at least using the same numeric format for all entries, like when printing vectors.