Skip to content
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

docs(Python): Add examples for polars.read_parquet and polars.read_parquet_schema #14847

Closed
30 changes: 30 additions & 0 deletions py-polars/polars/io/parquet/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ def read_parquet(
data will be stored continuously in memory. Set `rechunk=False` if you are
benchmarking the parquet-reader as `rechunk` can be an expensive operation
that should not contribute to the timings.

Examples
--------
>>> pl.read_parquet("ballondor.parquet") # doctest: +SKIP
shape: (3, 3)
┌──────┬─────────┬──────────┐
│ yr ┆ name ┆ country │
│ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ str │
╞══════╪═════════╪══════════╡
│ 1999 ┆ Rivaldo ┆ Brazil │
│ 2000 ┆ Figo ┆ Portugal │
│ 2001 ┆ Owen ┆ England │
└──────┴─────────┴──────────┘
"""
# Dispatch to pyarrow if requested
if use_pyarrow:
Expand Down Expand Up @@ -206,6 +220,22 @@ def read_parquet_schema(source: str | Path | IO[bytes] | bytes) -> dict[str, Dat
-------
dict
Dictionary mapping column names to datatypes

Examples
--------
>>> pl.read_parquet("ballondor.parquet") # doctest: +SKIP
shape: (3, 3)
┌──────┬─────────┬──────────┐
│ yr ┆ name ┆ country │
│ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ str │
╞══════╪═════════╪══════════╡
│ 1999 ┆ Rivaldo ┆ Brazil │
│ 2000 ┆ Figo ┆ Portugal │
│ 2001 ┆ Owen ┆ England │
└──────┴─────────┴──────────┘
>>> pl.read_parquet_schema("ballondor.parquet") # doctest: +SKIP
{'yr': Int64, 'name': String, 'country': String}
"""
if isinstance(source, (str, Path)):
source = normalize_filepath(source)
Expand Down
Loading