[ENH] Add polars
Engine Support to pd.read_csv()
#61988
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Pull Request: [ENH] Add
polars
Engine Support topd.read_csv()
β Problem Statement
Pandas'
read_csv()
function supports multiple engines like "c", "python", and "pyarrow" for reading CSV files. However, there is no built-in support for the high-performance Polars engine, which is known for its speed and efficiency in parsing large datasets.β Community Request: Feature proposed in Issue #61813
π οΈ Solution & Whatβs Included
This PR implements optional support for
engine="polars"
inpandas.read_csv()
by:Modifying
readers.py
:pl.read_csv(...).to_pandas()
to return a pandas DataFrame.Ensuring compatibility in engine validation:
Version Updates:
2.3.3.dev0
in:__init__.py
pyproject.toml
Testing:
pandas/tests/io/parser/test_read_csv_polars.py
π‘ Example Usage
Input file:
sample.csv
π― Expected Output
pandas.DataFrame
.polars
is installed.π Files Modified
pandas/io/parsers/readers.py
β Add polars engine logicpandas/__init__.py
β Version bump to2.3.3.dev0
pyproject.toml
β Version updatepandas/tests/io/parser/test_read_csv_polars.py
β New test file addedπ§ͺ Tests
Test name:
test_read_csv_with_polars
β Result: Passed with warning (unrelated deprecation from pyarrow)
π§· Notes
π Feedback welcome!