CodeSampleX

Ejemplo

pandas 3.0.5: merge, array, NA

Muestra verificada para pypi pandas 3.0.5: merge, array, NA. El contrato se ejecutó en python 3.14 · linux alpine/x64 · docker y pasó.

sha256:9497731711d6252100a5bf41c3ade2e4f710509e602c1db3f7ad78e8cea5d97d

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
2
Entorno declarado python 3.14 linux · musl x64 python 3.14 python 3.14 pip

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
python 3.14 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-19
python 3.14 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.14-alpine@sha256:05b2b8b732ec…
2026-09-08

Caso

HOW
Objetivo
verify pandas.merge in pkg:pypi/pandas@3.0.5
Paquetes
Símbolos
  • pandas.merge
  • pandas.array
  • pandas.NA
  • pandas.errors.MergeError
Entorno
python 3.14
Creado
2026-08-18T13:40:54Z

Contrato

  1. An outer top-level pandas.merge matches one missing Int64 key across both sides and reports three both, two left_only, and one right_only rows.
  2. validate='one_to_one' raises pandas.errors.MergeError when an ordinary left join key is duplicated.
  3. left_anti returns only keys 1 and 4 while right_anti returns only key 2, excluding the missing key because pandas treats it as matched.

Archivos

  • PROMPT.md
  • csx.json
  • requirements.lock
  • requirements.txt
  • spec.json
  • test/contract.py

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pandas.merge in pkg:pypi/pandas@3.0.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/pandas@3.0.5
Demonstrate these symbols/APIs:
  - pandas.merge
Required runtime conditions:
  - ecosystem: golang
  - language: go
  - packageManager: go@1.26.5
  - runtime: go@1.26.5

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:c01f2fb6a51dd5b611b5297b13e5cd2a1c64dd92976c09e3b133b37d990387ae","contract":["An outer top-level pandas.merge matches one missing Int64 key across both sides and reports three both, two left_only, and one right_only rows.","validate='one_to_one' raises pandas.errors.MergeError when an ordinary left join key is duplicated.","left_anti returns only keys 1 and 4 while right_anti returns only key 2, excluding the missing key because pandas treats it as matched."],"goal":"verify pandas.merge in pkg:pypi/pandas@3.0.5","kind":"HOW","packages":["pkg:pypi/pandas@3.0.5"],"schemaVersion":1,"symbols":["pandas.merge","pandas.array","pandas.NA","pandas.errors.MergeError"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","ecosystem":"pypi","executionContext":"python","language":"python","languageVersion":"3.14","libc":"musl","os":"linux","packageManager":"pip","runtime":"python","runtimeVersion":"3.14","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pandas@3.0.5"],"schemaVersion":1,"symbols":["pandas.merge","pandas.array","pandas.NA","pandas.errors.MergeError"],"verifierAdapter":"python@1"}
requirements.lock
numpy==2.5.2
pandas==3.0.5
python-dateutil==2.9.0.post0
six==1.17.0
requirements.txt
numpy==2.5.2
pandas==3.0.5
python-dateutil==2.9.0.post0
six==1.17.0
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pandas.merge in pkg:pypi/pandas@3.0.5",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/pandas@3.0.5"
  ],
  "symbols": [
    "pandas.merge"
  ],
  "runtimeConditions": {
    "ecosystem": "golang",
    "language": "go",
    "packageManager": "go@1.26.5",
    "runtime": "go@1.26.5"
  }
}
test/contract.py
import pandas as pd


def assert_merge_error(callback) -> None:
    try:
        callback()
    except pd.errors.MergeError:
        return
    raise AssertionError("expected pandas.errors.MergeError")


def make_frames() -> tuple[pd.DataFrame, pd.DataFrame]:
    left = pd.DataFrame(
        {
            "key": pd.array([1, None, 3, 3, 4], dtype="Int64"),
            "left_value": ["one", "missing", "three-a", "three-b", "four"],
        }
    )
    right = pd.DataFrame(
        {
            "key": pd.array([None, 2, 3], dtype="Int64"),
            "right_value": ["missing", "two", "three"],
        }
    )
    return left, right


def test_outer_merge_and_validation() -> None:
    left, right = make_frames()
    merged = pd.merge(
        left,
        right,
        on="key",
        how="outer",
        indicator=True,
        validate="many_to_many",
    )

    counts = merged["_merge"].astype("string").value_counts().to_dict()
    assert counts == {"both": 3, "left_only": 2, "right_only": 1}, counts

    missing = merged.loc[merged["key"].isna()]
    assert len(missing) == 1
    assert missing.iloc[0]["left_value"] == "missing"
    assert missing.iloc[0]["right_value"] == "missing"
    assert missing.iloc[0]["_merge"] == "both"

    assert_merge_error(
        lambda: pd.merge(left, right, on="key", validate="one_to_one")
    )


def test_anti_joins_treat_missing_keys_as_matches() -> None:
    left, right = make_frames()
    left_unique = left.drop_duplicates("key", keep="first")

    left_anti = pd.merge(left_unique, right, on="key", how="left_anti")
    right_anti = pd.merge(left_unique, right, on="key", how="right_anti")

    assert sorted(left_anti["key"].astype("int64").tolist()) == [1, 4]
    assert right_anti["key"].astype("int64").tolist() == [2]
    assert not left_anti["key"].isna().any()
    assert not right_anti["key"].isna().any()


if __name__ == "__main__":
    test_outer_merge_and_validation()
    test_anti_joins_treat_missing_keys_as_matches()
    print("pandas 3.0.5 top-level merge contract passed")

Seeder de origen

anónimo