CodeSampleX

示例

polars 1.43.2: Port pandas DataFrame code to polars on Alpine, without the wheel surprise or the silently wrong answers

已验证示例 — pypi polars 1.43.2: Port pandas DataFrame code to polars on Alpine, without the wheel surprise or the silently wrong answers. contract 在 python 3.12…

sha256:a238e626062c628c548646e46144b6aac21a07492cf10e1617eb4286c853ac05

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
2
构建过它的签名密钥
2
声明的环境 python 3.12 linux · musl x64 python 3.12 python pip

验证运行环境

环境 契约 阶段 运行日期
python 3.12 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pypi@1
2026-08-14
python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pypi@1
2026-08-18

案例

MIGRATION
目标
Port pandas DataFrame code to polars on Alpine, without the wheel surprise or the silently wrong answers
符号
  • polars.DataFrame
  • polars.LazyFrame
  • polars.col
  • polars.len
  • DataFrame.filter
  • DataFrame.select
  • DataFrame.with_columns
  • DataFrame.with_row_index
  • DataFrame.group_by
  • GroupBy.agg
  • LazyFrame.collect
  • LazyFrame.explain
  • LazyFrame.collect_schema
  • Expr.map_elements
  • Expr.alias
  • Series.is_null
  • Series.is_nan
  • Series.fill_null
  • Series.fill_nan
  • Series.eq_missing
  • polars.exceptions.ColumnNotFoundError
  • polars.exceptions.DuplicateError
  • polars.exceptions.PerformanceWarning
  • DataFrame.vstack
  • DataFrame.hstack
  • DataFrame.extend
  • DataFrame.insert_column
  • DataFrame.drop_in_place
环境
python 3.12
创建时间
2026-08-14T12:56:07Z

契约

  1. 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
  2. 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
  3. 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
  4. assert the interpreter reports musl and polars.__version__ agrees with the distribution metadata, which is the check a half-installed polars fails
  5. assert a DataFrame has none of index, loc, iloc, at, iat, values, reset_index, sort_values, assign, query or apply
  6. assert filtering renumbers rows from zero, and with_row_index before the filter is what carries the original positions through, as UInt32 data
  7. assert brackets take a column by name and a row by position, and an unknown name raises ColumnNotFoundError
  8. assert a boolean mask in brackets selects columns rather than rows, raising ValueError when its length does not match the column count
  9. assert the same mask on a frame with as many columns as rows returns the wrong columns with no error at all
  10. assert filter with a pl.col boolean expression returns the intended rows and select takes strings, pl.col and an anchored regex
  11. assert an Expr has no truth value, so `and` and `or` both raise TypeError, and dropping the parentheses around & raises that identical message
  12. assert separate positional predicates mean AND, and the keyword form is equality against a literal
  13. assert with_columns returns a new frame, leaves the input's columns and values untouched, and has no inplace parameter
  14. assert item assignment on a DataFrame raises TypeError naming DataFrame.with_columns as the replacement
  15. 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
  16. 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
  17. assert an unaliased expression is named after the first column it mentions, so with_columns replaces that column instead of adding one
  18. assert explain returns the plan as a string while the per-row Python hook has still not been called once
  19. assert the optimizer moves the filter below the projection, the reverse of both the unoptimized plan and the order written
  20. assert collect runs the hook on only the two surviving rows, where the identical eager pipeline runs it on all six
  21. assert a LazyFrame naming a missing column is built without complaint and raises ColumnNotFoundError only when the plan is resolved, which explain also does
  22. assert a LazyFrame has no shape, and asking it for columns emits a PerformanceWarning because that resolves the schema
  23. assert is_null and is_nan disagree on every hole, and is_nan over a null is null rather than False
  24. assert null_count reports one null while the mean is nan, count excludes the null and pl.len counts every row
  25. 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
  26. assert min and max ignore the NaN that sum and mean propagate
  27. assert comparison against a null yields null while eq_missing yields False
  28. 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
  29. assert nulls sort first in both directions unless nulls_last is set
  30. 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
  31. assert an integer column with a missing value stays Int64 and its aggregates skip the null on both sides of the division
  32. assert group_by returns the group keys first, then one column per agg expression in the order given
  33. assert maintain_order gives first-appearance order, which is not sorted order, and without it only the set of rows is defined
  34. assert two aggregates over one column collide as DuplicateError, worded one way inside agg and another inside select

文件

  • csx.json
  • requirements.txt
  • src/__init__.py
  • src/frames.py
  • src/install.py
  • test/contract.py

下载源代码构件 (tar.gz)

原始种子者

anonymous