A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/5543 below:

symmetric_difference for Index · Issue #5543 · pandas-dev/pandas · GitHub

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4