Repository navigation
BUG: keep the dtype of an empty object on setitem-with-expansion (GH#19647) - #71961
Closed
jbrockmendel wants to merge 3 commits into
Closed
jbrockmendel wants to merge 3 commits into
jbrockmendel wants to merge 3 commits into
Conversation
…19647) Adding a new label via .loc or Series.__setitem__ to an empty Series or DataFrame with a non-object dtype now keeps that dtype when it can hold the value exactly, instead of re-inferring from the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…GH#19647) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
On reflection, I think we should just get a void dtype in place and get this right |
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.
Partial fix for GH-19647: the dtype-retention piece only, not the broader "any"-dtype proposal.
Adding a new label via
.locorSeries.__setitem__to an empty Series or DataFrame with a non-object dtype now keeps that dtype when it can hold the value exactly. Previously the dtype was re-inferred from the value, so e.g. an emptyfloat64Series becameint64afterser.loc[0] = 1, and a later float insert then raised the GH-62369 incompatible-dtype warning.True->1, no float rounding) and a later insert of the same value would also keep it. For example, a tz-mismatchedTimestampinto an empty UTC column still follows main, because retaining UTC would send the next insert to object.AI disclosure: drafted with Claude Code (
claude opus 5.5 (high)), used for the implementation, tests, and iterative review against main.