Skip to content
Back to skills

Polars Knowledge Patch

ASecurity

Polars

  • 25 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 5, 2026
developmentpythongosqlexpressawsgcpazureapidatabaseperformance

Works with

  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill polars-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Polars Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Polars Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-polars-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-polars-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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 expressions,
data types, I/O, lazy execution, streaming, SQL, or interoperability.
Use the references for detailed behavior, examples, and version attribution.

## Reference index

| Reference | Topics |
| --- | --- |
| [Migration and Core API](references/migration-and-core-api.md) | Constructors, indexing, assignment, pivots, joins, grouping, sorted merges, imports |
| [Expressions and Data Types](references/expressions-and-data-types.md) | Casting, categorical data, nested values, strings, temporal operations, windows, callbacks |
| [I/O, Cloud Storage, and Databases](references/io-cloud-and-databases.md) | Parquet, CSV, JSON, spreadsheets, credentials, databases, Delta, Lance, Iceberg catalogs |
| [Lazy Execution, Streaming, and SQL](references/lazy-streaming-and-sql.md) | Schemas, optimization, sinks, remote execution, out-of-core settings, SQL syntax and semantics |
| [Serialization, Runtime, and Arrow](references/serialization-runtime-and-arrow.md) | Plan serialization, Python compatibility, dependencies, Arrow, NumPy, expression plugins |

## Breaking behavior: expressions and mutation

`Expr.str.find` and `Expr.str.find_many` now return character offsets.
`pl.lit("éx").str.find("x")` returns `1`. For byte offsets on binary data,
use `Expr.bin.find` and `Expr.bin.find_many`.

Arguments required to be scalar must resolve to one value at planning time.
Supply a literal when migrating calls that used row-dependent expressions.
The `element` argument to `list.count_matches` and `arr.count_matches`
must also be scalar.

For `Series.scatter`, a replacement sequence must have the same length as
the indices. Both `scatter` and Series index assignment cast replacements
to the target column's dtype. Extra keys in records passed to `pl.from_dicts`
can now raise; normalize record keys when you need to discard extra fields.

Eager arithmetic between strings and numbers raises in 2.1. Cast numeric
strings to a numeric dtype before arithmetic. Adding or subtracting a
non-temporal Series to or from a temporal Series now raises; use a typed
duration for an offset, such as `pl.col("ts") + pl.duration(days=1)`.

`DELETE` now mutates the table registered in the `SQLContext`. Registered
tables also support `INSERT` and `UPDATE`. An `INSERT` or `DELETE` that
reads its target table evaluates that read when it runs.

## Deprecations and replacements

- `replace` preserves input dtype and deprecates `default` and `return_dtype`.
  Use `replace_strict` for mappings that change dtype. Unmapped non-null
  values raise unless you supply a default.
- Direct string-to-temporal casts are deprecated. Parse with `str.to_date`,
  `str.to_datetime`, or `str.to_time`.
- Categorical-to-integer and numeric-to-Categorical casts are deprecated.
  Use `pl.col("label").cat.physical()` for category codes and `cat.to` for a
  different category set. `cat.get_categories()`, `cat.to_local()`, and
  `pl.StringCache` are deprecated.
- Casting a non-nested column to `List` is deprecated. `pl.list("value")`
  packs singleton lists; `pl.list("a", "b")` packs both values per row.
  List-valued inputs remain nested elements.
- Mixed Boolean/integer bitwise operations are deprecated. For an integer
  bitmask, cast the Boolean operand to the integer operand's dtype first.
- `struct.rename_fields()` deprecates a mismatched number of names; supply
  one name per field in field order.
- Omitting `plan_stage` in `LazyFrame.show_graph()` is deprecated.
- Omit deprecated cache arguments to `pl.scan_ipc`. Drop the deprecated
  `ddof` argument to `pl.rolling_corr`; it is ignored.
- `cut` and `qcut` are deprecated in 2.0, which introduces new binning functions.
- The `__dataframe__` interchange integration is deprecated. For Arrow table
  exchange, export with `df.to_arrow()` and import with `pl.from_arrow(table)`.
- Update the deprecated `polars-cloud` dependency to `polars-nanook`.

## Construction, indexing, and reshaping

With `strict=False`, omitting `dtype` infers a common type for mixed values;
supplying it casts to that type. For example,
`pl.Series([1, 2, 3.5], dtype=pl.Int8, strict=False)` contains `[1, 2, 3]`.
Strict cast overflow raises `pl.exceptions.InvalidOperationError`; update
handlers that caught `ComputeError`. Strict casts also check nested values.

Frame orientation is inferred from input and schema dimensions. Inferred
row orientation warns; pass `orient="row"` for row data, especially when
both dimensions are equal. Two-dimensional NumPy inputs produce Series
of fixed-size arrays. Two-dimensional `reshape` produces `Array`; use
`.arr.to_list()` when downstream code needs `List`.

`get` and `gather` raise on out-of-bounds indices by default. Use
`null_on_oob=True` for null results. For `explode`, pass `empty_as_null`
explicitly: `True` emits a null row for an empty list; `False` emits zero rows.

`arg_min` and `arg_max` may return any index tied for the extremum. Select
the first occurrence explicitly when required. `index_of` returns the
first matching position on Series and expressions.

## Nulls, precision, and windows

`ewm_mean`, `ewm_std`, and `ewm_var` return null at null input rows. To restore
filled output, call `forward_fill()` on the result. With `bias=False`, the
first observation yields null in `ewm_var` and `ewm_std`.

`rolling_*_by` returns null for rows with null `by` values and accepts
index-count windows over integer indices, such as `window_size="3i"`.
`group_by_dynamic` defaults to zero offset, which can drop the preceding
partial window when `period` exceeds `every`.

Decimal `sum()` widens precision and raises on overflow. Temporal `total_*`
functions return null on conversion overflow. `quantile` can evaluate its
fraction separately per group in `group_by`; a null fraction yields null.

`approx_quantile` works in both in-memory and streaming engines and is
available in SQL. Sketch states can be merged across processes; 2.1 adds
deterministic merging of finalized sketches.

## Lazy execution, streaming, and memory

`LazyFrame` access to `schema`, `dtypes`, `columns`, or `width` emits
`PerformanceWarning`. Use `lf.collect_schema()` to resolve a `Schema`.
`LazyFrame.match_to_schema` aligns a lazy frame to a target schema.

The streaming engine is stable: select it with `lf.collect(engine="streaming")`.
The `LazyFrame.sink_*` methods are stable APIs for writing query results.
Pass a `RemoteEngine` as `engine` to `LazyFrame.collect` or
`LazyFrame.collect_batches` to execute remotely.

Configure lazy optimization with `QueryOptFlags`, for example:

```python
lf.collect(optimizations=pl.QueryOptFlags(predicate_pushdown=False))
```

`LazyFrame.map_batches` disables optimizations by default. When opting into
pushdown, ensure the callback gives equivalent results if filtering, column
selection, or slicing occurs before it runs.

Polars 2.0 enables out-of-core processing by default with a threshold of
80% of available RAM and a 64 GB disk budget. Set
`POLARS_OOC_DISK_BUDGET_MB=4096` for a 4096 MB spill budget.
`POLARS_OOMKILL_THRESHOLD_MB` configures the kill threshold in MB; in 2.1
it can also be a fraction, the default prefetch fraction is 0.5, and the
default spill compression level is 1. The default dirty-page limit is now
80% of total memory. Streaming equi-joins can spill their build side to disk.

## Scans, storage, and credentials

Parquet directory inputs infer Hive partitions by default. File paths,
file lists, and globs require `hive_partitioning=True` to opt in.
Parquet scans validate dtypes only for projected columns. `cast_options`
can reconcile types across files, for example:

```python
pl.scan_parquet("parts/*.parquet", cast_options=pl.ScanCastOptions(integer_cast="upcast"))
```

CSV `infer_schema_files` controls how many files schema inference samples,
separately from the row limit `infer_schema_length`. With
`pl.scan_csv(..., missing_columns="insert")`, missing columns are filled
with nulls for that input while other column values are preserved.

`scan_parquet` accepts experimental `credential_provider` support for AWS
and GCP. Automatic Azure storage-account key use requires opting in;
the configured `tenant_id` is forwarded to `CredentialProviderAzure`.
The default cloud connection timeout is now 10 seconds.

`pl.scan_database` builds a lazy database query and can push supported
filters to the database. `pl.scan_delta` reads partition values from the
Delta transaction log; Delta reads raise for column-mapped tables.
`scan_lance` opens Lance data lazily; its 2.0 API is unstable.
GeoParquet read/write support in 2.1 is experimental.

## SQL semantics and query features

`DataFrame.sql` and `LazyFrame.sql` are frame-scoped. Top-level `pl.sql`
can resolve DataFrames in the surrounding Python scope, for example:

```python
pl.sql("SELECT * FROM df1 CROSS JOIN df2", eager=True)
```

SQL `/` uses true division, including integer operands. `DIV` truncates
toward zero, and `%` uses the corresponding remainder. A literal such as
`1.25` has dtype `Decimal`. `SUM` and `CORR` return `NULL` for all-null
inputs; use `TOTAL(amount)` when the all-null sum should be zero.

If an unmatched ID encounters `NULL` in a `NOT IN` subquery, the predicate
is unknown and `WHERE id NOT IN (...)` drops the row. Use
`ON l.key IS NOT DISTINCT FROM r.key` to match null join keys.

In grouped queries, SQL windows operate on aggregated rows. `QUALIFY` runs
before final projection, and tied ordering keys share the same running
aggregate in ordered windows. In 2.1, `HAVING` can filter a single aggregate
group without an explicit `GROUP BY`.

SQL supports query parameters, macros, recursive CTEs, lateral joins,
grouping sets, `PIVOT`, and `UNPIVOT`. Quoted file paths can appear directly
in `FROM` and `DESCRIBE`; file reads can be disabled on the `SQLContext`.
Attached Iceberg catalogs support SQL DDL, writes, maintenance, time travel,
tags, and branches; see the I/O reference for the individual operations.

## Serialization and Python compatibility

`serialize()` and `deserialize()` on `DataFrame`, `LazyFrame`, and `Expr`
default to binary. Wrap in-memory binary output in `io.BytesIO` to
deserialize, or specify `format="json"` on both calls. `pl.read_json`
interprets a serialized frame as row data; use
`pl.DataFrame.deserialize("frame.json", format="json")` for that format.

Deserialization rejects incompatible serialized DSL representations.
Retain query-building code to regenerate plans for the target version.
Credential-provider objects are omitted from serialized lazy plans;
configure credentials in the environment executing the deserialized plan.

Python UDF deserialization checks the Python version; use the same Python
version for serializing and deserializing a plan containing a UDF. Polars
attempts to load pickle payloads created with a different Python version.
Polars 2.1 drops Python 3.10 support; use Python 3.11 or later when upgrading.

Files in this skill

  • SKILL.md9.6 KB
  • coverage.json940 B
  • references/expressions-and-data-types.md7.1 KB
  • references/io-cloud-and-databases.md6.3 KB
  • references/lazy-streaming-and-sql.md5.7 KB
  • references/migration-and-core-api.md7.9 KB
  • references/serialization-runtime-and-arrow.md4.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.