Skip to content

polars/polars-pandas-round-trip

Rule polars-pandas-round-trip
Pack Polars
Severity info
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

A Polars to pandas to Polars round trip converts the data twice. Keep the original frame when no pandas operation is needed.

pl.from_pandas(df.to_pandas())
df

The integer-only round trip matched the original frame on 50,000 and 500,000 rows.

Use xpd check --fix --unsafe-fixes to remove the pl.from_pandas(df.to_pandas()) round trip.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

A Polars to pandas to Polars round trip converts the data twice. Keep the original frame when no pandas operation is needed.

Browse the other rules of the Polars pack.