Beispiel
Port pandas DataFrame code to polars on Alpine, without the wheel surprise or the silently wrong answers
sha256:a238e626062c628c548646e46144b6aac21a07492cf10e1617eb4286c853ac05
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Port pandas DataFrame code to polars on Alpine, without the wheel surprise or the silently wrong answers MIGRATION
- Pakete
- polars 1.43.2 polars-runtime-32 1.43.2
- Umgebung
- python 3.12
- Erstellt
- 2026-08-14T12:56:07Z
Contract
- assert pip took the musllinux wheel for the engine, polars_runtime_32-1.43.2-cp310-abi3-musllinux_1_2_x86_64.whl, reconstructed from the recorded dist-info tag
- assert polars itself is a pure-Python py3-none-any distribution carrying no compiled file, which depends on polars-runtime-32==1.43.2 for the engine
- assert the engine's shared object is named .abi3.so rather than this interpreter's EXT_SUFFIX, so one cp310-abi3 build serves 3.12
- assert the interpreter reports musl and polars.__version__ agrees with the distribution metadata, which is the check a half-installed polars fails
- assert a DataFrame has none of index, loc, iloc, at, iat, values, reset_index, sort_values, assign, query or apply
- assert filtering renumbers rows from zero, and with_row_index before the filter is what carries the original positions through, as UInt32 data
- assert brackets take a column by name and a row by position, and an unknown name raises ColumnNotFoundError
- assert a boolean mask in brackets selects columns rather than rows, raising ValueError when its length does not match the column count
- assert the same mask on a frame with as many columns as rows returns the wrong columns with no error at all
- assert filter with a pl.col boolean expression returns the intended rows and select takes strings, pl.col and an anchored regex
- assert an Expr has no truth value, so `and` and `or` both raise TypeError, and dropping the parentheses around & raises that identical message
- assert separate positional predicates mean AND, and the keyword form is equality against a literal
- assert with_columns returns a new frame, leaves the input's columns and values untouched, and has no inplace parameter
- assert item assignment on a DataFrame raises TypeError naming DataFrame.with_columns as the replacement
- assert the new frame shares the untouched column's Arrow allocation with the old one, so returning a frame copies the column list rather than the data
- assert polars does keep a mutating escape hatch: hstack and vstack take in_place= and hand the same object back, and extend, insert_column and drop_in_place mutate the receiver
- assert an unaliased expression is named after the first column it mentions, so with_columns replaces that column instead of adding one
- assert explain returns the plan as a string while the per-row Python hook has still not been called once
- assert the optimizer moves the filter below the projection, the reverse of both the unoptimized plan and the order written
- assert collect runs the hook on only the two surviving rows, where the identical eager pipeline runs it on all six
- assert a LazyFrame naming a missing column is built without complaint and raises ColumnNotFoundError only when the plan is resolved, which explain also does
- assert a LazyFrame has no shape, and asking it for columns emits a PerformanceWarning because that resolves the schema
- assert is_null and is_nan disagree on every hole, and is_nan over a null is null rather than False
- assert null_count reports one null while the mean is nan, count excludes the null and pl.len counts every row
- assert a column holding a NaN and no null reports null_count zero with a nan mean, so a missing-data check written as null_count() == 0 passes on it
- assert min and max ignore the NaN that sum and mean propagate
- assert comparison against a null yields null while eq_missing yields False
- assert polars orders NaN above every number and compares it equal to itself, the opposite of Python, so a > 0 filter keeps the NaN and drops the null
- assert nulls sort first in both directions unless nulls_last is set
- assert drop_nulls keeps NaN and drop_nans keeps null, neither fill touches the other's hole, and fill_nan(None) collapses the two into one
- assert an integer column with a missing value stays Int64 and its aggregates skip the null on both sides of the division
- assert group_by returns the group keys first, then one column per agg expression in the order given
- assert maintain_order gives first-appearance order, which is not sorted order, and without it only the set of rows is defined
- assert two aggregates over one column collide as DuplicateError, worded one way inside agg and another inside select
Dateien
- csx.json
- requirements.txt
- src/__init__.py
- src/frames.py
- src/install.py
- test/contract.py
Ursprungs-Seeder
Verifizierungsbelege
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pypi@1 · 2026-08-14 · ed25519:a2ec939a4c60e243
- · CONTAINER_RUN · compile:SKIPPED · contract:FAIL · load:SKIPPED · resolve:PASS · pypi@1 · 2026-08-14 · ed25519:7da3f610facce8bf