You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Issue description
pl.DataFrame Columns of dtype pl.Int8, pl.UInt8, pl.Int16, and pl.UInt16 turn into pl.Int32 after a pickle roundtrip. pl.LazyFrame schema is unchanged by pickle and converting to/from a pandas pd.DataFrame also leaves schema unchanged.
Reproducible example
importpolarsasplfrompolarsimportcolimportpicklefordtypeinpl.NUMERIC_DTYPES:
df=pl.DataFrame(data={"A":[1, 2, 3]}).with_columns(col("A").cast(dtype))
before=df.schemaafter=pickle.loads(pickle.dumps(df)).schemaifbefore!=after:
# Int8, UInt8, Int16, UInt16 change to Int32print(f"pl.Dataframe: dtype {before['A']} changes to {after['A']} after pickle")
after=pickle.loads(pickle.dumps(df.lazy())).schemaifbefore!=after:
# dtypes unchangedprint(f"pl.LazyFrame: dtype {before['A']} changes to {after['A']} after pickle")
after=pl.from_pandas(pickle.loads(pickle.dumps(df.to_pandas()))).schemaifbefore!=after:
# dtypes unchangedprint(f"pd.DataFrame: dtype {before['A']} changes to {after['A']} after pickle")
>>>pl.Dataframe: dtypeInt16changestoInt32afterpickle>>>pl.Dataframe: dtypeUInt8changestoInt32afterpickle>>>pl.Dataframe: dtypeUInt16changestoInt32afterpickle>>>pl.Dataframe: dtypeInt8changestoInt32afterpickle
Expected behavior
Schema of DataFrame should be unchanged after a pickle round trip
Polars version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Issue description
pl.DataFrame
Columns of dtypepl.Int8
,pl.UInt8
,pl.Int16
, andpl.UInt16
turn intopl.Int32
after apickle
roundtrip.pl.LazyFrame
schema is unchanged bypickle
and converting to/from a pandaspd.DataFrame
also leaves schema unchanged.Reproducible example
Expected behavior
Schema of DataFrame should be unchanged after a
pickle
round tripInstalled versions
The text was updated successfully, but these errors were encountered: