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

Allow non-inplace option for ndframe.update() #31372

Closed
giuliobeseghi opened this issue Jan 27, 2020 · 0 comments
Closed

Allow non-inplace option for ndframe.update() #31372

giuliobeseghi opened this issue Jan 27, 2020 · 0 comments

Comments

@giuliobeseghi
Copy link

giuliobeseghi commented Jan 27, 2020

Code Sample, a copy-pastable example if possible

import pandas as pd

s = pd.Series([1, 2, 3, 4, 5])
t = pd.Series([10, 11, 12], index=range(3, 6))

print(s.update(t).reindex([1, 2, 3, 4, 5]))

Problem description

Obviously the previous doesn't work. s.update(t) is executed inplace, and doesn't return anything. I see no reasons why one shouldn't be able to call update and get a new object (for example to allow method chaining).

The easiest way of implementing this is by allowing a parameter that makes the function return the updated object:

print(s.update(t, inplace=False).reindex([1, 2, 3, 4, 5]))

I know there is already a plan about deprecating inplace, but I'm not sure it involves update. I guess that update was designed to be similar to the same method of a dict object.

Update
Closed as it was solved in #10730

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

No branches or pull requests

1 participant