Skip to content

ENH: other join types than 'left' for .update #8805

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

Open
maxgrenderjones opened this issue Nov 13, 2014 · 6 comments
Open

ENH: other join types than 'left' for .update #8805

maxgrenderjones opened this issue Nov 13, 2014 · 6 comments
Labels
Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@maxgrenderjones
Copy link
Contributor

Running 0.15.1

DataFrame.update(other, join='left', overwrite=True, filter_func=None, raise_conflict=False)
    Modify DataFrame in place using non-NA values from passed DataFrame. Aligns on indices

    Parameters :    
    other : DataFrame, or object coercible into a DataFrame
    join : {‘left’, ‘right’, ‘outer’, ‘inner’}, default ‘left’

But..

C:\Anaconda\lib\site-packages\pandas\core\frame.pyc in update(self, other, join, overwrite, filter_func, raise_conflict)
   3292         # TODO: Support other joins
   3293         if join != 'left':  # pragma: no cover
-> 3294             raise NotImplementedError("Only left join is supported")
   3295 
   3296         if not isinstance(other, DataFrame):

NotImplementedError: Only left join is supported
@jorisvandenbossche
Copy link
Member

Yes, the docs should better mention that (care to do a PR?)

Or we should implement it of course.

@jorisvandenbossche jorisvandenbossche added this to the 0.16.0 milestone Nov 13, 2014
@jreback jreback modified the milestones: 0.15.2, 0.16.0 Nov 27, 2014
jreback added a commit that referenced this issue Nov 28, 2014
@jorisvandenbossche
Copy link
Member

Closed by #8912

@jreback
Copy link
Contributor

jreback commented Nov 28, 2014

I left this open for an eventual impl

@jorisvandenbossche jorisvandenbossche changed the title Docs imply join types other than left are implemented for .update when they aren't ENH: other join types than 'left' for .update Nov 28, 2014
@jorisvandenbossche
Copy link
Member

@jreback ok, changed the title and labels to reflect that then

jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this issue Dec 1, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@mroeschke mroeschke added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Dec 25, 2019
@debnathshoham
Copy link
Member

Hi, I want to pick this up. But I am a little confused about how right, inner and outer would behave.

In df1.update(df2, join)

  1. Would df2 change for join=right?
  2. For join=inner, df1 would retain only the common indices
  3. For join=outer additional indices from df2 would be added to df

Maybe some example about the expecetd behaviours would be really helpful.

@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
@pascal456
Copy link

pascal456 commented Dec 10, 2023

I looked for a solution that would do something like what I would expect to achieve with

.update(other, join='outer')

But after a while I realized that ther is already
pandas.DataFrame.combine_first

So, when I am not mistaken, the case join='outer' is already implemented.

Assumption: you apply this in the correct order. Since with .update, I expect other to overwrite the original, while combine_first keeps the original value, if there are values in both the DataFrames. Which means you would rather say outer.combine_first(original).

Thoughts on this? This should be added to the docs I would say. Took me while to realize this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

6 participants