Skip to content

Commit dc8285f

Browse files
author
Abu Jabar Mubarak
authored
Handle engine='polars'
1 parent fb4f24e commit dc8285f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/io/parsers/readers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,24 @@ def _read(
679679
kwds["parse_dates"] = False
680680
else:
681681
kwds["parse_dates"] = True
682+
# 🆕 Handle engine='polars'
683+
if kwds.get("engine") == "polars":
684+
try:
685+
import polars as pl
686+
except ImportError:
687+
raise ImportError(
688+
"Polars is not installed. Please install it with 'pip install polars'."
689+
)
690+
691+
pl_args = {}
692+
if "nrows" in kwds:
693+
pl_args["n_rows"] = kwds["nrows"]
694+
if "encoding" in kwds:
695+
pl_args["encoding"] = kwds["encoding"]
696+
697+
df = pl.read_csv(filepath_or_buffer, **pl_args)
698+
return df.to_pandas()
699+
682700

683701
# Extract some of the arguments (pass chunksize on).
684702
iterator = kwds.get("iterator", False)

0 commit comments

Comments
 (0)