Skip to content

Guard deprecated concat copy keyword by pandas version in BatchExample.py - #648

Open
xyf5432 wants to merge 1 commit into
gtri:Ubuntu-24.04from
xyf5432:fix/pandas3-concat-copy-deprecation
Open

Guard deprecated concat copy keyword by pandas version in BatchExample.py#648
xyf5432 wants to merge 1 commit into
gtri:Ubuntu-24.04from
xyf5432:fix/pandas3-concat-copy-deprecation

Conversation

@xyf5432

@xyf5432 xyf5432 commented Aug 24, 2026

Copy link
Copy Markdown

Fixes #647

Changes

Guard the deprecated copy keyword of pd.concat by pandas version in
scripts/BatchExample.py, so behaviour is preserved on every supported
version:

  • scripts/BatchExample.py: module-level
    PANDAS_VERSION = Version(pd.__version__) (from packaging, already a
    transitive dependency of pandas), and

    if PANDAS_VERSION < Version("3.0"):
        agg = pd.concat([agg, frame], copy=False)
    else:
        agg = pd.concat([agg, frame])

    — the same pattern as Fix pandas 3 string dtype compatibility and CI flakes NVIDIA/cuml#8142.

Verification

The copy keyword never affects the result of concat on any
pandas version, only whether input buffers are copied; the branch keeps
that behaviour exactly as it was on each side of the boundary. Runtime
checks in isolated venvs:

  • pandas 2.3.3 takes the copy=False branch: identical results to
    today's code (per-run row accumulation across *_job_* csvs), no
    warning.
  • pandas 3.0.5 takes the plain branch: no Pandas4Warning is emitted,
    results identical (the copy keyword is a documented no-op under
    Copy-on-Write).
  • Modified file passes python -m py_compile.

In pandas 3.0, copy-on-write is enabled by default and the copy keyword
of pd.concat is deprecated. Only pass copy=False when running on
pandas < 3.0 to preserve the original behavior and avoid the
Pandas4Warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pd.concat(..., copy=False) in BatchExample.py emits Pandas4Warning on pandas ≥3.0 — drop the deprecated copy keyword

1 participant