Guard deprecated concat copy keyword by pandas version in BatchExample.py - #648
Open
xyf5432 wants to merge 1 commit into
Open
Guard deprecated concat copy keyword by pandas version in BatchExample.py#648xyf5432 wants to merge 1 commit into
xyf5432 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #647
Changes
Guard the deprecated
copykeyword ofpd.concatby pandas version inscripts/BatchExample.py, so behaviour is preserved on every supportedversion:
scripts/BatchExample.py: module-levelPANDAS_VERSION = Version(pd.__version__)(frompackaging, already atransitive dependency of pandas), and
— the same pattern as Fix pandas 3 string dtype compatibility and CI flakes NVIDIA/cuml#8142.
Verification
The
copykeyword never affects the result ofconcaton anypandas 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:
copy=Falsebranch: identical results totoday's code (per-run row accumulation across
*_job_*csvs), nowarning.
Pandas4Warningis emitted,results identical (the
copykeyword is a documented no-op underCopy-on-Write).
python -m py_compile.