Skip to content

Fix: Add to_pandas_kwargs to read_parquet for PyArrow engine #58981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def read(
dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
storage_options: StorageOptions | None = None,
filesystem=None,
to_pandas_kwargs: dict[str, Any] | None = None,
**kwargs,
) -> DataFrame:
kwargs["use_pandas_metadata"] = True
Expand Down Expand Up @@ -280,7 +281,7 @@ def read(
"make_block is deprecated",
DeprecationWarning,
)
result = pa_table.to_pandas(**to_pandas_kwargs)
result = pa_table.to_pandas(**(to_pandas_kwargs or {}))

if pa_table.schema.metadata:
if b"PANDAS_ATTRS" in pa_table.schema.metadata:
Expand Down Expand Up @@ -505,6 +506,7 @@ def read_parquet(
dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
filesystem: Any = None,
filters: list[tuple] | list[list[tuple]] | None = None,
to_pandas_kwargs: dict[str, Any] | None = None,
**kwargs,
) -> DataFrame:
"""
Expand Down Expand Up @@ -540,6 +542,11 @@ def read_parquet(
If not None, only these columns will be read from the file.
{storage_options}

to_pandas_kwargs : dict, default None
Additional keyword arguments passed to :meth:`pyarrow.Table.to_pandas`
to control how the pyarrow Table is converted to a pandas DataFrame.
This is only used when `engine="pyarrow"`.

.. versionadded:: 1.3.0

dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable'
Expand Down Expand Up @@ -649,5 +656,6 @@ def read_parquet(
storage_options=storage_options,
dtype_backend=dtype_backend,
filesystem=filesystem,
to_pandas_kwargs=to_pandas_kwargs,
**kwargs,
)
Loading