Skip to content

Polars

Introduced in v4.0

The Polars backend is experimental and is subject to backwards incompatible changes.

Install

Install ibis and dependencies for the Polars backend:

pip install 'ibis-framework[polars]'
conda install -c conda-forge ibis-polars
mamba install -c conda-forge ibis-polars

Connect

API

Create a client by passing in connection parameters to ibis.polars.connect.

See ibis.backends.polars.Backend.do_connect for connection parameter information.

ibis.polars.connect is a thin wrapper around ibis.backends.polars.Backend.do_connect.

Connection Parameters

do_connect(tables=None)

Construct a client from a dictionary of polars.LazyFrames.

Parameters:

Name Type Description Default
tables MutableMapping[str, pl.LazyFrame] | None

An optional mapping of string table names to polars LazyFrames.

None

Backend API

Backend

Bases: BaseBackend

Functions

read_csv(path, table_name=None, **kwargs)

Register a CSV file as a table in the current database.

Parameters:

Name Type Description Default
path str | Path

The data source. A string or Path to the CSV file.

required
table_name str | None

An optional name to use for the created table. This defaults to a sequentially generated name.

None
**kwargs Any

Additional keyword arguments passed to Polars loading function. See https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.scan_csv.html for more information.

{}

Returns:

Type Description
ir.Table

The just-registered table

read_pandas(source, table_name=None, **kwargs)

Register a Pandas DataFrame or pyarrow Table a table in the current database.

Parameters:

Name Type Description Default
source pd.DataFrame

The data source.

required
table_name str | None

An optional name to use for the created table. This defaults to a sequentially generated name.

None
**kwargs Any

Additional keyword arguments passed to Polars loading function. See https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.from_pandas.html for more information.

{}

Returns:

Type Description
ir.Table

The just-registered table

read_parquet(path, table_name=None, **kwargs)

Register a parquet file as a table in the current database.

Parameters:

Name Type Description Default
path str | Path

The data source(s). May be a path to a file or directory of parquet files.

required
table_name str | None

An optional name to use for the created table. This defaults to a sequentially generated name.

None
**kwargs Any

Additional keyword arguments passed to Polars loading function. See https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.scan_parquet.html for more information.

{}

Returns:

Type Description
ir.Table

The just-registered table

register(source, table_name=None, **kwargs)

Register a data source as a table in the current database.

Parameters:

Name Type Description Default
source str | Path | Any

The data source(s). May be a path to a file, a parquet directory, or a pandas dataframe.

required
table_name str | None

An optional name to use for the created table. This defaults to a sequentially generated name.

None
**kwargs Any

Additional keyword arguments passed to Polars loading functions for CSV or parquet. See https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.scan_csv.html and https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.scan_parquet.html for more information

{}

Returns:

Type Description
ir.Table

The just-registered table


Last update: January 9, 2023