I read in a stored numpy array with dtype object in polars.
I want to change colomn dtype from object to float in the polars dataframe.
Minimal example:
# generate sample data
data = {"1": ["1.0", "2.0", "3.0", "4.0"],
"2": [10, 20, 30, 40]}
df = pl.DataFrame(data, schema={'1':pl.Object, '2':pl.Object})
# what I want to do
df.with_columns(pl.col('2').cast(pl.Float64, strict=False))
last line yields error:
polars.exceptions.ComputeError: cannot cast ‘Object’ type
How can I do this?