Skip to content

REF: Remove sanitize_column from _iset_item #51702

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 4 commits into from
Mar 1, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Feb 28, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

this should work ootb. Don't think we need a copy here

arraylike = self._sanitize_column(value)
self._iset_item_mgr(loc, arraylike, inplace=True)
def _iset_item(self, loc: int, value: Series) -> None:
self._iset_item_mgr(loc, value._values, inplace=True)
Copy link
Member

Choose a reason for hiding this comment

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

i think this is OK only because iset_item is called only from replace_columnwise which guarantees no reindex is necessary. can you add a comment to that effect?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a comment, we have to keep the copy until reference tracking for setitem works properly (meaning the value that is set into the DataFrame).

Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

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

LGTM

@jbrockmendel
Copy link
Member

BTW one of your other recent PRs that avoided passing DataFrame to sanitize_column might make it so that the allow_2d=True passed there could be unnecessary?

@phofl
Copy link
Member Author

phofl commented Mar 1, 2023

I think we could still get there with 2D arrays, not sure though. Would have to check

@phofl phofl merged commit ce32601 into pandas-dev:main Mar 1, 2023
@phofl phofl deleted the replace_columnwise branch March 1, 2023 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants