Format Dataframe

eweiss
Thu, 13 Jul 2023 21:23:05 +0000
General Usage

I have a dataframe with columns of numbers and strings. I would like to format it like an Excel spreadsheet so the numbers have dollar signs, commas, and 2 decimals.

df = DataFrame(
StringColumn = [“A”, “B”, “C”, “D”, “E”],
FloatColumn = [112345.23, 1214.56, 7.899, 0.12, 3.45]
)

I’ve tried @sprintf(“%.2f”, df.FloatColumn), but it doesn’t like getting a vector.
Trying to broadcase @sprintf.(“%.2f”, df.FloatColumn) is not valid either.

I know we don’t usually use Julia when a pretty format is needed, but in this case I need to.

Any suggestions? Use a call to C?

4 posts - 3 participants