Skip to content

ENH: symmetric_difference for Index #5543

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

Closed
TomAugspurger opened this issue Nov 18, 2013 · 0 comments · Fixed by #6016
Closed

ENH: symmetric_difference for Index #5543

TomAugspurger opened this issue Nov 18, 2013 · 0 comments · Fixed by #6016
Labels
API Design Enhancement Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@TomAugspurger
Copy link
Contributor

I've had to use this a few times, maybe some other people could use it too.

At least for unique indices, the symmetric difference should be equivalent to (df1.index - df2.index).union(df2.index - df1.index). Example:

In [54]: df1 = pd.DataFrame([1,2,3,4], index=['a', 'b', 'c', 'd'])

In [55]: df1
Out[55]: 
   0
a  1
b  2
c  3
d  4

In [56]: df2 = pd.DataFrame([5, 6, 7, 8], index=['a', 'd', 'e', 'f'])

In [57]: df2
Out[57]: 
   0
a  5
d  6
e  7
f  8

In [58]: (df1.index - df2.index).union(df2.index - df1.index)
Out[58]: Index([u'b', u'c', u'e', u'f'], dtype='object')

I'll need to look into how would work for

  • Indicies with duplicates
  • MultiIndexes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Enhancement Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant