Guard deprecated astype copy keyword by pandas version in encode_values_into_bin_idx - #48
Open
xyf5432 wants to merge 1 commit into
Open
Conversation
…es_into_bin_idx The copy keyword of Series.astype is deprecated in pandas 3.0 (Pandas4Warning). Pass it only on pandas <3.0, where it still avoids an extra copy when the dtype is unchanged; omit it on >=3.0 where it is a documented no-op under Copy-on-Write. Co-Authored-By: Claude <noreply@anthropic.com>
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.
PR: Guard deprecated astype copy keyword by pandas version in encode_values_into_bin_idx
Fixes #47
Changes
Guard the deprecated
copykeyword ofSeries.astypeby pandasversion in
DateTimeAttribute.encode_values_into_bin_idx, so behaviouris preserved on every supported version:
DataSynthesizer/datatypes/DateTimeAttribute.py: module-levelPANDAS_VERSION = Version(pd.__version__)(frompackaging, alreadya transitive 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 ofastypeon anypandas version, only whether an extra copy is made; the branch keeps
that behaviour exactly as it was on each side of the boundary. Runtime
checks on pandas 2.3.3 and 3.0.5 (Series →
fillna→ branch):copy=Falsebranch, results identical.Pandas4Warningis emitted,results identical (the
copykeyword is a documented no-op underCopy-on-Write).
python -m py_compile.