{"data":{"kind":"file","path":"README.md","version_id":"mi62ap0hivrnwgzrd6in5yjg","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":6054,"modified_at":"2026-08-07T06:29:56.641000","content_hash":"8d3991f1e5d5f57bd21047526b17eb02e5269c710ef4f9e7c42b40c0048c7909"},"entries":[],"content":"# pandas-env\r\n\r\n### Overview\r\n- **Environment ID**: `pandas-env`\r\n- **Short description**: RL environment for pandas DataFrame tasks using expected_output comparison\r\n- **Tags**: pandas, dataframe, data-manipulation\r\n\r\n### Datasets\r\n- **Primary dataset(s)**: `eltociear/pandas-tasks-v1` — pandas tasks across multiple categories\r\n- **Source links**: [HuggingFace Dataset](https://huggingface.co/datasets/eltociear/pandas-tasks-v1)\r\n- **Split sizes**: train (43 examples)\r\n\r\n### Task Categories\r\n\r\n| Category | Description |\r\n|----------|-------------|\r\n| Cleaning | Missing values, duplicates, whitespace/case, group-wise imputation, date coercion, outliers |\r\n| Transformation | Derived columns, conditional binning, projection, renaming, sorting, filtering, window ranks, casting |\r\n| Joins | Inner/left/full outer/anti/semi joins, lookup with default |\r\n| Aggregation | GroupBy sums and means, multi-key counts, named aggregations, per-group top row, broadcast transforms |\r\n| Time Series | Resampling, lags, rolling means, datetime components, date filters, diffs |\r\n| Reshaping | melt, pivot_table, crosstab, distinct values |\r\n\r\n### Task\r\n- **Type**: Multi-turn tool use (default `max_turns=5`)\r\n- **Rubric overview**: Binary pass/fail using `pandas.testing.assert_frame_equal` to compare the model's DataFrame to the expected output\r\n\r\n### Quickstart\r\n\r\nRun a small eval (env defaults are `num_examples=5`, `rollouts_per_example=3`):\r\n\r\n```bash\r\nuv run vf-eval pandas-env -p prime -m openai/gpt-5.4-nano -s\r\n```\r\n\r\nFull sweep:\r\n\r\n```bash\r\nuv run vf-eval pandas-env -p prime -m openai/gpt-5.4-mini -n 43 -r 3 -s\r\n```\r\n\r\n### Environment Arguments\r\n\r\n| Arg | Type | Default | Description |\r\n|-----|------|---------|-------------|\r\n| `split` | str | `\"train\"` | Dataset split to use |\r\n| `dataset_name` | str | `\"eltociear/pandas-tasks-v1\"` | HuggingFace dataset name |\r\n| `max_turns` | int | `5` | Maximum interaction turns per task |\r\n\r\n### Tools Available\r\n- `execute_code(code: str)` — run Python/pandas in the sandbox; `df` (or `df1`/`df2`) is preloaded and frame state persists across turns\r\n- `bash(command: str)` — run shell commands in the sandbox\r\n\r\n### Grading\r\n\r\nThe expected output never enters the sandbox — it is held host-side and compared after the\r\nrollout, so the model cannot read the answer key.\r\n\r\nComparison is `assert_frame_equal`, which checks **column order, row order, the index and\r\ndtypes** as well as values. Prompts therefore state index handling and any non-obvious dtype\r\nexplicitly, so a correct solution is never ambiguous.\r\n\r\nA wrong answer scores `0.0` silently. A *broken scorer* scores `0.0` and additionally sets\r\n`state[\"scoring_error\"]`, so eval runs can distinguish \"the model was wrong\" from \"the harness\r\nfailed\" instead of silently blaming the model.\r\n\r\n### Building the dataset\r\n\r\n`build_tasks.py` generates and verifies the dataset. Tasks are defined as (deterministic input\r\nframes, instruction, reference solution) and the expected output is **computed** by running the\r\nreference solution, never hand-written, so the answer key cannot drift from the instruction.\r\n\r\n```bash\r\npython build_tasks.py --verify          # check every task\r\npython build_tasks.py --out train.jsonl # regenerate the dataset\r\n```\r\n\r\n`--verify` independently checks that each task: runs without error and returns a DataFrame; is\r\ndeterministic across two executions; produces a non-empty result; produces a result that is\r\n**not** identical to its input (an identity task carries no learning signal); and that both the\r\nresult and every input frame survive the serialisation round-trip exactly, dtypes included.\r\nAll 43 tasks pass.\r\n\r\n## Environment arguments\r\n\r\n`load_environment()` deliberately exposes very little: the program's guidance is that an\r\nenvironment should have one correct way to be run, so nothing about the prompts, the parsing or\r\nthe grading is configurable.\r\n\r\n| Argument | Default | Meaning |\r\n|---|---|---|\r\n| `split` | `'train'` | Dataset split to load. |\r\n| `dataset_name` | `'eltociear/pandas-tasks-v1'` | Hugging Face dataset of tasks. Change only to point at a fork. |\r\n| `max_turns` | `5` | Tool-use turns the model gets before the rollout ends. |\r\n| `**kwargs` | — | Passed through to the underlying `SandboxEnv`. |\r\n\r\n## Reward rubric\r\n\r\n| Reward function | Weight | What it returns |\r\n|---|---|---|\r\n| `correctness` | 1.0 | Binary: 1.0 when the answer matches the reference, else 0.0. |\r\n\r\nThere is no LLM judge and no partial credit. The score is computed on the host in\r\n`post_rollout` and read back by the rubric, so the reward is a deterministic function of the\r\nvalues the model left in `result`. A **harness** failure (dead sandbox, unreadable read-back)\r\nalso scores 0.0 but additionally sets `state[\"scoring_error\"]`, so an eval run can tell a\r\nbroken harness from a wrong answer instead of blaming the model.\r\n\r\n## Dependencies\r\n\r\n`datasets>=4.1.0`, `pandas>=2.2.0`, `pyarrow>=15.0.0`, `verifiers>=0.1.8`\r\n\r\n## Sample `vf-eval` usage\r\n\r\n```bash\r\nuv run vf-install pandas-env\r\nuv run vf-eval -s pandas-env -m gpt-4.1 -n 5 -r 3\r\nuv run vf-tui                      # inspect the outputs/ folder it writes\r\n```\r\n\r\n### Known limitation\r\n\r\nThe Docker **sandbox transport** has not been executed — `docker run`, `pip install`, and the\r\nmodel's code running inside the container — because that needs a Docker runtime and an\r\ninference provider key, neither available where this was authored.\r\n\r\nEverything else is exercised. `environments/test_scoring_path.py` runs this environment's\r\n`post_rollout` and `Rubric` with the sandbox mocked out, asserting that a correct answer scores\r\n1.0, a well-formed wrong answer scores 0.0, and a dead sandbox scores 0.0 *and* sets\r\n`scoring_error` so a harness failure is never mistaken for a bad model. It also checks that\r\nwhat `build_tasks.py` emits is exactly what the scorer expects. The environment mirrors the\r\nstructure of `polars_env` (already accepted into the Environments Program) and imports cleanly\r\nagainst `verifiers` 0.2.1.\r\n","encoding":"utf-8","truncated":false,"total_bytes":6054},"status":null}