Skip to content

Conversation

@itholic
Copy link
Contributor

@itholic itholic commented Oct 25, 2019

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.symmetric_difference.html#pandas.Index.symmetric_difference

>>> s1 = ks.Series([1, 2, 3, 4], index=[1, 2, 3, 4])
>>> s2 = ks.Series([1, 2, 3, 4], index=[2, 3, 4, 5])

>>> s1.index.symmetric_difference(s2.index)
Int64Index([5, 1], dtype='int64')

>>> s1.index.symmetric_difference(s2.index, result_name='koalas')
Int64Index([5, 1], dtype='int64', name='koalas')

>>> s1.index.symmetric_difference(s2.index, sort=True)
Int64Index([1, 5], dtype='int64')

>>> s1.index ^ s2.index
Int64Index([5, 1], dtype='int64')

For MultiIndex

>>> midx1 = pd.MultiIndex([['lama', 'cow', 'falcon'],
...                        ['speed', 'weight', 'length']],
...                       [[0, 0, 0, 1, 1, 1, 2, 2, 2],
...                        [0, 0, 0, 0, 1, 2, 0, 1, 2]])
>>> midx2 = pd.MultiIndex([['koalas', 'cow', 'falcon'],
...                        ['speed', 'weight', 'length']],
...                       [[0, 0, 0, 1, 1, 1, 2, 2, 2],
...                        [0, 0, 0, 0, 1, 2, 0, 1, 2]])
>>> s1 = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3],
...                index=midx1)
>>> s2 = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3],
...              index=midx2)

>>> s1.index.symmetric_difference(s2.index)
MultiIndex([('koalas', 'speed'),
            (  'lama', 'speed')],
           )

>>> s1.index.symmetric_difference(s2.index, result_name=['a', 'b'])
MultiIndex([('koalas', 'speed'),
            (  'lama', 'speed')],
           names=['a', 'b'])

>>> s1.index.symmetric_difference(s2.index, sort=True)
MultiIndex([('koalas', 'speed'),
            (  'lama', 'speed')],
           )

>>> s1.index ^ s2.index
MultiIndex([('koalas', 'speed'),
            (  'lama', 'speed')],
           )

@codecov-io
Copy link

codecov-io commented Oct 25, 2019

Codecov Report

Merging #953 into master will decrease coverage by 0.08%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #953      +/-   ##
==========================================
- Coverage   94.52%   94.43%   -0.09%     
==========================================
  Files          34       34              
  Lines        6466     6510      +44     
==========================================
+ Hits         6112     6148      +36     
- Misses        354      362       +8
Impacted Files Coverage Δ
databricks/koalas/missing/indexes.py 100% <ø> (ø) ⬆️
databricks/koalas/indexes.py 92.11% <95.45%> (-4.34%) ⬇️
databricks/koalas/missing/frame.py 100% <0%> (ø) ⬆️
databricks/koalas/plot.py 94.28% <0%> (ø) ⬆️
databricks/koalas/missing/series.py 100% <0%> (ø) ⬆️
databricks/koalas/frame.py 96.03% <0%> (ø) ⬆️
databricks/koalas/base.py 94.9% <0%> (+0.06%) ⬆️
databricks/koalas/series.py 96.32% <0%> (+0.22%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f53aeb...35876f8. Read the comment docs.

@softagram-bot
Copy link

Softagram Impact Report for pull/953 (head commit: 35876f8)

⭐ Change Overview

Showing the changed files, dependency changes and the impact - click for full size
(Open in Softagram Desktop for full details)

📄 Full report

Impact Report explained. Give feedback on this report to [email protected]

You can set names of result Index.
>>> s1.index.symmetric_difference(s2.index, result_name=['a', 'b']) # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

Why did we skip this @itholic ?

Copy link
Contributor Author

@itholic itholic Nov 18, 2019

Choose a reason for hiding this comment

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

@HyukjinKwon because the way of print out for MultiIndex are different depends on their python version 😲

@HyukjinKwon
Copy link
Member

Seems fine.

@HyukjinKwon HyukjinKwon merged commit 5c59a82 into databricks:master Nov 19, 2019
@ueshin
Copy link
Collaborator

ueshin commented Nov 19, 2019

Shall we explicitly block the cases MultiIndex ^ Index or Index ^ MultiIndex for now?

@HyukjinKwon
Copy link
Member

The tests are being failed after this commit anyway. I will revert this commit. @itholic do you mind opening a PR again to address test failures and Takuya's comment above?

@itholic
Copy link
Contributor Author

itholic commented Nov 19, 2019

@HyukjinKwon sure, i'm going to address in separated PR.

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.

5 participants