BUG: DataFrame.loc setitem with list-like value on single-column EA DataFrame#65241
Merged
mroeschke merged 2 commits intopandas-dev:mainfrom Apr 21, 2026
Merged
BUG: DataFrame.loc setitem with list-like value on single-column EA DataFrame#65241mroeschke merged 2 commits intopandas-dev:mainfrom
mroeschke merged 2 commits intopandas-dev:mainfrom
Conversation
…ataFrame (pandas-dev#44103) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mroeschke
reviewed
Apr 20, 2026
| def test_loc_setitem_single_column_listlike_value(self): | ||
| # GH#44103 | ||
| df = DataFrame({"a": [None, "two"]}, index=[0, 1], dtype="string") | ||
| df.loc[0, ["a"]] = ["one"] |
Member
There was a problem hiding this comment.
Do we have tests with assignment across multiple columns e.g. ["a", "b"]] = ["1", "2"]?
Member
Author
There was a problem hiding this comment.
updated with a new test
mroeschke
reviewed
Apr 20, 2026
| and len(indexer) == 2 | ||
| and is_integer(indexer[0]) | ||
| and not is_integer(indexer[1]) | ||
| and is_list_like(value) |
Member
There was a problem hiding this comment.
Do we need to check that len(values) == len(indexer) - 1?
Member
Author
There was a problem hiding this comment.
i think that is already handled within the split path
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mroeschke
approved these changes
Apr 21, 2026
Member
|
Thanks @jbrockmendel |
Sharl0tteIsTaken
added a commit
to Sharl0tteIsTaken/pandas
that referenced
this pull request
Apr 22, 2026
…h-origin * upstream/main: (31 commits) DOC:Missing r in your (pandas-dev#65323) DOC: fix grammar in the .dt accessor section (pandas-dev#65325) REGR: restore rank() for ExtensionArrays with custom values for sorting (pandas-dev#64976) BUG: MultiIndex.get_loc returns scalar for unique key in non-unique index (pandas-dev#65234) BUG/TST: add test for _cast_pointwise_result robustness + fix some cases (pandas-dev#65318) BUG: fix .loc with tuple key on MultiIndex with IntervalIndex level (pandas-dev#65239) BUG: permit building from source with mingw (pandas-dev#64849) BUG: DataFrame.loc setitem with list-like value on single-column EA DataFrame (pandas-dev#65241) PERF: preserve block memory layout in Block.copy (GH#60469) (pandas-dev#65302) PERF: short-circuit sort_index(level=...) on monotonic non-MultiIndex (pandas-dev#65279) BUG: fix FloatingArray.astype(str) crash with distinguish_nan_and_na=True (pandas-dev#65038) BUG: fix to_timedelta ignoring unit for mixed round/non-round floats (pandas-dev#65170) BUG: DataFrame.loc preserves original index name when key is an Index (pandas-dev#65229) REF: continue moving freq management off DatetimeArray/TimedeltaArray (GH#24566) (pandas-dev#65285) REF: remove redundant BaseMaskedArray.map override (pandas-dev#65297) Bump github/codeql-action from 4.35.1 to 4.35.2 (pandas-dev#65310) Bump actions/setup-node from 6.3.0 to 6.4.0 (pandas-dev#65309) BUG: Fix formatters applied to wrong columns in truncated DataFrame.to_string (GH#35410) (pandas-dev#65288) PERF: optimize block consolidation (pandas-dev#64574) CLN: Replace no_default signature with False for allow_duplicates in insert and reset_index (pandas-dev#65146) ...
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.
Summary
df.loc[row, [col]] = [val]raisingValueErroron single-column DataFrames with ExtensionArray dtypes (e.g.string,Int64)_setitem_single_blocknow processes column-by-column when the indexer selects a scalar row and array-like columns with a list-like value, matching the split-path behaviorcloses #44103
Test plan
test_loc_setitem_single_column_listlike_value— sets with a plain listtest_loc_setitem_single_column_ea_value— sets with apd.array🤖 Generated with Claude Code