polars icon indicating copy to clipboard operation
polars copied to clipboard

Decimals not formatted correctly in ouput (decimal places missing)

Open Julian-J-S opened this issue 1 year ago • 0 comments

Checks

  • [X] I have checked that this issue has not already been reported.
  • [X] I have confirmed this bug exists on the latest version of Polars.

Reproducible example

pl.DataFrame(
    {
        "x": [1, 1.2, 1.23],
    }
).with_columns(
    d=pl.col("x").cast(pl.Decimal(scale=2)),
)

Log output

shape: (3, 2)
┌──────┬───────────────┐
│ x    ┆ d             │
│ ---  ┆ ---           │
│ f64  ┆ decimal[38,2] │
╞══════╪═══════════════╡
│ 1.0  ┆ 1             │ >>>>>> no decimal places shown?!
│ 1.2  ┆ 1.20          │
│ 1.23 ┆ 1.23          │
└──────┴───────────────┘

Issue description

decimals that have no "fraction" are displayed without the specified "scale"/digits

Expected behavior

All values should be formatted with the given "scale"! (this is also the case in spark/pyspark)

Installed versions

0.20.5

Julian-J-S avatar Jan 25 '24 13:01 Julian-J-S