Skip to content

BUG: loc casting to object for multi block case when setting with list indexer #49161

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
Oct 19, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Oct 17, 2022

@phofl phofl added the Indexing Related to indexing on series/frames, not to indexes themselves label Oct 17, 2022
# setting with a list, re-coerces
self._setitem_single_column(loc, value[:, i].tolist(), pi)
value_col = value[:, i]
if is_object_dtype(value_col):
Copy link
Member

Choose a reason for hiding this comment

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

nitpick value_col -> value_col.dtype

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed

@@ -1898,16 +1898,20 @@ def _setitem_with_indexer_2d_value(self, indexer, value):

ilocs = self._ensure_iterable_column_indexer(indexer[1])

# GH#7551 Note that this coerces the dtype if we are mixed
Copy link
Member

Choose a reason for hiding this comment

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

is the GH reference here worth keeping somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think so, since we are avoiding this now

self._setitem_single_column(loc, value[:, i].tolist(), pi)
value_col = value[:, i]
if is_object_dtype(value_col):
# try coerce values as good as possible
Copy link
Member

Choose a reason for hiding this comment

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

the wording here is pretty kludgy, maybe "casting to list so that we do type inference in setitem_single_column"

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed, thx

@mroeschke mroeschke added this to the 2.0 milestone Oct 18, 2022
@mroeschke mroeschke merged commit a9acc52 into pandas-dev:main Oct 19, 2022
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the 49159 branch October 20, 2022 08:46
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
…t indexer (pandas-dev#49161)

* BUG: loc casting to object for multi block case when setting with list indexer

* Remove xpasses

* Fix windows

* Adress comments

* Remove condition
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: wrong values produced when setting using .loc
3 participants