Skip to content
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

ENH: Remove for loop from DataFrame.update() #56303

Closed

Conversation

smij720
Copy link
Contributor

@smij720 smij720 commented Dec 2, 2023

It's not clear to me why DataFrame.update() needs to perform the update one column at a time.

I'd be interested to get any feedback on this, and if it's of interest I can think through any edge cases and add some more tests etc.

(this is my first contribution to the actual code, rather than docs, so if I'm missing something obvious please let me know!)

Thanks!

  • 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.

@smij720 smij720 marked this pull request as draft December 2, 2023 23:00
Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

This is a huge performance degradation, see comment below why

for col in self.columns.intersection(other.columns):
this = self[col]._values
that = other[col]._values
cols = self.columns.intersection(other.columns)
Copy link
Member

Choose a reason for hiding this comment

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

Calling ._values on multiple columns converts to a common dtype for all columns, probably object as soon as you have non-numeric columns. This is terrible from a performance perspective, so doing this at once is actually a lot slower in real world use cases than doing one column at a time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, understood. Thank you for taking the time to explain.

@smij720 smij720 closed this Dec 3, 2023
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