Open JulianCologne opened 4 months ago
I think #14209 fixes this issue.
This got me through this issue. Maybe it can help anyone that has a Decimal column and is trying to save the DataFrame to a csv file:
import polars as pl
copy = df
# Get data types of columns
column_dtypes = copy.dtypes
for i in range(len(column_dtypes)):
c_type = column_dtypes[i]
if c_type.is_decimal():
column = df.columns[i]
print(f'Converting {column} to Float')
copy = copy.with_columns(copy[column].cast(pl.Float64))
copy.write_csv("test.csv")
@MarceloCFerraz the same can be done in polars in just one line
df.with_columns(pl.col(pl.Decimal).cast(pl.Float64))
However, this is a workaround for some use cases but not an ideal solution 😄
Checks
Reproducible example
Log output
Issue description
DataFrames containing columns of
Decimal
type cannot be written to csvExpected behavior
It is possible to display/print a dataframe so it should be possitlbe to also write
Decimal
to csv.Installed versions