Skip to content

BUG: is_scalar_indexer #32850

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 5 commits into from
Mar 20, 2020
Merged

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

ATM we go through the wrong path when setting a listlike entry in a single position.

The broader goal: separate out the cases where setitem is inplace vs copying.

@jorisvandenbossche
Copy link
Member

Is there an actual bug that this fixes? (do you have an example with indexing that now did the wrong thing?)

@jbrockmendel
Copy link
Member Author

Is there an actual bug that this fixes? (do you have an example with indexing that now did the wrong thing?)

Nothing user-facing, just an unnecessary failed-cast:

df = DataFrame(index=[0, 1], columns=[0])
df.iloc[1, 0] = [1, 2, 3]

ATM this incorrectly doesnt see the indexer as a scalar-indexer, but does see this (also incorrectly) as an exact_match, so goes through the try/except in L906-909. This is why the try/except is needed in the first place.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

small comment, otherwise lgtm.

values = values.astype(arr_value.dtype)
except ValueError:
pass
values = values.astype(arr_value.dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

can add copy=False here I think

@jreback jreback added Clean Indexing Related to indexing on series/frames, not to indexes themselves labels Mar 20, 2020
@jreback jreback added this to the 1.1 milestone Mar 20, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. merge on green.

@jbrockmendel jbrockmendel merged commit 4f9bc8a into pandas-dev:master Mar 20, 2020
@jbrockmendel jbrockmendel deleted the setitem-exact_match branch March 20, 2020 20:40
SeeminSyed pushed a commit to CSCD01-team01/pandas that referenced this pull request Mar 22, 2020
* BUG: is_scalar_indexer

* update docstring

* add copy=False
jbrockmendel added a commit to jbrockmendel/pandas that referenced this pull request Mar 23, 2020
* BUG: is_scalar_indexer

* update docstring

* add copy=False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants