polars icon indicating copy to clipboard operation
polars copied to clipboard

ComputeError when writing `Decimal` type to csv using `write_csv`

Open Julian-J-S opened this issue 11 months ago • 1 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": ["0.1", "0.2"]})
    .with_columns(pl.col("x").cast(pl.Decimal))
    .write_csv("decimal.csv")
)

# shape: (2, 1)
# ┌──────────────┐
# │ x            │
# │ ---          │
# │ decimal[*,1] │
# ╞══════════════╡
# │ 0.1          │
# │ 0.2          │
# └──────────────┘

Log output

ComputeError: datatype 0.1 cannot be written to csv

Issue description

DataFrames containing columns of Decimal type cannot be written to csv

Expected behavior

It is possible to display/print a dataframe so it should be possitlbe to also write Decimal to csv.

Installed versions

0.20.11

Julian-J-S avatar Feb 29 '24 13:02 Julian-J-S