Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Polars Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-polars-knowledge-patch)
---
name: polars-knowledge-patch
description: Polars
version: "2.2.0"
license: MIT
metadata:
author: Nevaberry
---
# Polars compatibility guidance
Load this skill when migrating Polars code or working with its Python expressions,
lazy execution, storage integrations, Rust plugins, or SQL behavior.
Use the quick reference below for breaking changes and common APIs; load the
relevant topic file for complete guidance and version-specific attribution.
## Reference index
| Reference | Topics |
| --- | --- |
| [Migration and deprecations](references/migration-and-deprecations.md) | Python support, dependencies, removed and deprecated APIs, scalar arguments, validation |
| [Data types and expressions](references/data-types-and-expressions.md) | Construction, indexing, nested data, nulls, strings, temporal values, windows, aggregates, plugins |
| [I/O and serialization](references/io-and-serialization.md) | Parquet, CSV, JSON, Arrow, NumPy, spreadsheets, cloud credentials, databases, Delta, Iceberg, Lance, serialized plans |
| [Lazy execution and joins](references/lazy-execution-and-joins.md) | Schema resolution, streaming, out-of-core settings, optimization, remote collection, joins, sorted merges |
| [SQL](references/sql.md) | Query scope, registered tables, file queries, grouping, windows, joins, subqueries, expressions, Iceberg catalogs |
## Breaking changes and deprecations
### Python version support
Polars 2.1 drops support for Python 3.10. Use Python 3.11 or later when upgrading.
### Nanook package rename
The remote execution package is now `polars-nanook`. Update dependency specifications that use the deprecated `polars-cloud` package.
### Character and byte offsets
`Expr.str.find` and `Expr.str.find_many` now report offsets in characters. For example, `pl.lit("éx").str.find("x")` returns `1`. Use the new `Expr.bin.find` and `Expr.bin.find_many` on binary data when you need byte offsets.
### Scalar arguments at planning time
Arguments that a function requires to be scalar must resolve to a single value at planning time. Supply a literal for those arguments when migrating calls that used row-dependent expressions. The `element` argument to `list.count_matches` and `arr.count_matches` must also be scalar.
### Replacement that changes dtype
`replace` preserves the input dtype and deprecates its `default` and `return_dtype` parameters. Use `replace_strict` for mappings that change dtype. Unmapped non-null values raise unless you supply a default.
```python
s = pl.Series([1, 2, 3])
s.replace_strict(1, "a", default=s) # ["a", "2", "3"]
```
### String-to-temporal casts
Direct casts from strings to temporal dtypes are deprecated. Parse explicitly with `str.to_date`, `str.to_datetime`, or `str.to_time`, as in `pl.col("day").str.to_date("%Y-%m-%d")`.
### Categorical casts and namespace
Casts from `Categorical` to integer dtypes and from numeric dtypes to `Categorical` are deprecated. Use `pl.col("label").cat.physical()` to retrieve category codes and `cat.to` to convert to a different category set. Calls to `cat.get_categories()` and `cat.to_local()` are also deprecated.
### List construction
Casting a non-nested column to `List` is deprecated. Use `pl.list("value")` to pack each value into a singleton list, or `pl.list("a", "b")` to pack both values into a list per row. List-valued inputs are kept as nested elements.
### Dataframe interchange protocol
Polars deprecates its `__dataframe__` interchange integration. For Arrow table exchange, export with `df.to_arrow()` and import with `pl.from_arrow(table)`.
### Binning deprecations
The `cut` and `qcut` APIs are deprecated in 2.0, which introduces new binning functions.
### Explicit graph plan stage
Omitting `plan_stage` in `LazyFrame.show_graph()` is deprecated. For example, `lf.show_graph(plan_stage="physical", engine="streaming", raw_output=True)` returns the physical streaming plan as DOT.
### Explicit handling of empty lists in `explode`
Pass `empty_as_null` explicitly. Use `df.explode("items", empty_as_null=True)` to emit a null row for an empty list, or pass `False` to emit zero rows for it.
### Out-of-bounds indexing defaults
`get` and `gather` operations now raise by default on out-of-bounds indices. Use `null_on_oob=True` where null results are desired, as in `pl.Series([[0, 1], [0]]).list.get(1, null_on_oob=True)`.
### Exceptions from strict casts
A strict cast such as `pl.Series([100, 200, 300]).cast(pl.UInt8)` now raises `pl.exceptions.InvalidOperationError` on overflow. Update handlers that caught `ComputeError` for this failure.
### Series scatter validation and coercion
When `Series.scatter` receives a sequence of replacement values, its length must match the number of indices. Both `scatter` and Series index assignment cast replacement values to the target column's dtype.
### Extra dictionary keys
Extra keys in records passed to `pl.from_dicts` can now raise. Normalize the record keys before construction when you need to discard extra fields.
## I/O and serialized-plan compatibility
### Hive partitioning for Parquet paths
`read_parquet` and `scan_parquet` infer Hive partition columns by default for directory inputs. For file paths, lists of files, and globs, opt in explicitly with `pl.scan_parquet("dataset/*/*.parquet", hive_partitioning=True)`.
### Row-oriented JSON I/O
`DataFrame.write_json()` writes records by row and drops the `row_oriented` and `pretty` arguments. Use `pl.DataFrame.deserialize("frame.json", format="json")` for a serialized frame, since `pl.read_json` interprets the serialized object as row data.
### Binary serialization by default
`serialize()` and `deserialize()` on `DataFrame`, `LazyFrame`, and `Expr` now default to binary. Wrap in-memory binary output in `io.BytesIO` for deserialization, or pass `format="json"` on both calls to use JSON.
### Excel engine options
The default `calamine` engine rejects `engine_options`. To keep using options intended for the former default, call `pl.read_excel("data.xlsx", engine="xlsx2csv", engine_options={"skip_empty_lines": True})`.
### Credentials in serialized plans
Polars omits credential-provider objects when serializing a lazy plan. Configure credentials in the environment that will execute the deserialized plan.
### Delta column mapping
Delta reads now raise for tables with column mapping enabled.
## Lazy query configuration
### Optimization defaults for batch UDFs
`LazyFrame.map_batches` disables optimizations by default. When opting into a pushdown, ensure the callback yields equivalent results if filtering, column selection, or slicing happens before it runs.
### Lazy query optimization flags
Configure lazy query optimizations with `QueryOptFlags`. For example, `lf.collect(optimizations=pl.QueryOptFlags(predicate_pushdown=False))` disables predicate pushdown for that collection.
### LazyFrame schema access
Accessing `schema`, `dtypes`, `columns`, or `width` on a `LazyFrame` now emits `PerformanceWarning`. Use `lf.collect_schema()` to resolve the schema explicitly and get a `Schema` object.
## Expression and query features
### Stable streaming engine
The streaming engine is stable. Select it with `lf.collect(engine="streaming")`.
### Lazy database reads
Use `pl.scan_database` to build a lazy query over a database source. The scan can push supported filters to the database.
### Row columns in evaluation expressions
`list.eval`, `arr.eval`, and `cumulative_eval` can reference other input columns. For example, `pl.col("items").list.eval(pl.element() + pl.col("offset"))` adds the row's offset to each list element. SQL lambdas can also reference columns from their enclosing row.
### Per-row replacement patterns
`str.replace` and `str.replace_all` accept an expression for the pattern. For example, `pl.col("text").str.replace_all(pl.col("pattern"), "_")` uses each row's own pattern.
### Format specifications
`pl.format` accepts format specifications, as in `pl.format("{:.2f}", pl.col("amount"))`. SQL `PRINTF` and `FORMAT` support format specifications too.
### Matching a lazy frame to a schema
`LazyFrame.match_to_schema` aligns a lazy frame to a target schema. For example, `lf.match_to_schema({"id": pl.Int64, "label": pl.String})` places `id` before `label` in a frame with those column types.
### Selectors as join keys
The `join` API accepts column selectors as keys. For example, `left.join(right, on=cs.starts_with("key_"))` uses matching key columns selected by `polars.selectors`.
### Full non-equi joins
Use `left.join_where(right, pl.col("x") < pl.col("y"), how="full")` to retain unmatched rows from both inputs in a non-equi join.
### Remote collection
Pass a `RemoteEngine` as `engine` to `LazyFrame.collect` or `LazyFrame.collect_batches` to execute the lazy query remotely.
### Approximate quantiles
`approx_quantile` works in both the in-memory and streaming engines and is available in SQL as `SELECT APPROX_QUANTILE(score, 0.95) AS p95 FROM scores`. Sketch states can be merged across processes, and 2.1 adds deterministic merging of finalized sketches.
## SQL behavior and file access
### SQL writes to registered tables
`DELETE` now mutates the table registered in the `SQLContext`. For example, `ctx.execute("DELETE FROM events WHERE expired", eager=True)` removes rows from `events` for subsequent queries. Registered tables also support `INSERT` and `UPDATE`, and an `INSERT` or `DELETE` that reads its target table evaluates that read when it runs.
### SQL HAVING without GROUP BY
In 2.1, `HAVING` can filter a single aggregate group without an explicit `GROUP BY`. For example, `SELECT COUNT(*) AS n FROM sales HAVING COUNT(*) > 0` returns the count only when the table contains rows.
### Exact SQL decimals and truncated division
A SQL literal such as `1.25` has dtype `Decimal`. SQL `DIV` truncates toward zero and `%` uses the corresponding remainder, so `SELECT -7 DIV 3 AS q, -7 % 3 AS r` yields `-2` and `-1`.
### SQL file paths
SQL accepts quoted file paths directly in `FROM` and `DESCRIBE`, as in `SELECT * FROM 'events.parquet'`. File reads can be disabled on the `SQLContext`, and the SQL `read_csv` function accepts the `empty_string_is_null` option.