Skip to content

Bug in iloc.setitem orienting IntegerArray into the wrong direction #41288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented May 3, 2021

This is more or less a follow up of #39040, so don't think we need a whatsnew?

@phofl phofl added Indexing Related to indexing on series/frames, not to indexes themselves NA - MaskedArrays Related to pd.NA and nullable extension arrays labels May 3, 2021
@@ -164,7 +164,7 @@ def check_setitem_lengths(indexer, value, values) -> bool:
# a) not necessarily 1-D indexers, e.g. tuple
# b) boolean indexers e.g. BoolArray
if is_list_like(value):
if len(indexer) != len(value):
if len(indexer) != len(value) and values.ndim == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the ndim check here be necessary if EAs all supported 2D?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we are passing here through with something like

df = pd.DataFrame(data={
    'col1': [1, 2, 3, 4],
    'col2': [3, 4, 5, 6],
    'col3': [6, 7, 8, 9],
})
rhs = np.array([1, 2, 3])
df.iloc[[1]] = rhs

too. This should set row-wise, but the check assumes it sets column-wise

@jreback jreback added this to the 1.3 milestone May 4, 2021
@@ -31,6 +31,7 @@
PeriodIndex,
Series,
Timestamp,
array,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought we are using pd.array rather than bare array (i could be out of date here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not know that. Changed it

@jreback jreback merged commit c89b19f into pandas-dev:master May 5, 2021
@jreback
Copy link
Contributor

jreback commented May 5, 2021

thanks @phofl very nice as always

@phofl
Copy link
Member Author

phofl commented May 5, 2021

Thanks @jreback

@phofl phofl deleted the 40933 branch May 5, 2021 19:51
topper-123 added a commit to topper-123/pandas that referenced this pull request May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Inconsistency for iloc between np.array and pd.array
3 participants