|
36 | 36 | from databricks.koalas.internal import _InternalFrame |
37 | 37 | from databricks.koalas.missing.indexes import _MissingPandasLikeIndex, _MissingPandasLikeMultiIndex |
38 | 38 | from databricks.koalas.series import Series |
39 | | -from databricks.koalas.internal import _InternalFrame |
40 | 39 | from databricks.koalas.utils import name_like_string |
41 | 40 |
|
42 | 41 |
|
@@ -465,70 +464,6 @@ def copy(self, name=None): |
465 | 464 | result.name = name |
466 | 465 | return result |
467 | 466 |
|
468 | | - def symmetric_difference(self, other, result_name=None, sort=None): |
469 | | - """ |
470 | | - Compute the symmetric difference of two Index objects. |
471 | | -
|
472 | | - Parameters |
473 | | - ---------- |
474 | | - other : Index or array-like |
475 | | - result_name : str |
476 | | - sort : True or None, default None |
477 | | - Whether to sort the resulting index. |
478 | | - * True : Attempt to sort the result. |
479 | | - * None : Do not sort the result. |
480 | | -
|
481 | | - Returns |
482 | | - ------- |
483 | | - symmetric_difference : Index |
484 | | -
|
485 | | - Notes |
486 | | - ----- |
487 | | - ``symmetric_difference`` contains elements that appear in either |
488 | | - ``idx1`` or ``idx2`` but not both. Equivalent to the Index created by |
489 | | - ``idx1.difference(idx2) | idx2.difference(idx1)`` with duplicates |
490 | | - dropped. |
491 | | -
|
492 | | - Examples |
493 | | - -------- |
494 | | - >>> s1 = ks.Series([1, 2, 3, 4], index=[1, 2, 3, 4]) |
495 | | - >>> s2 = ks.Series([1, 2, 3, 4], index=[2, 3, 4, 5]) |
496 | | -
|
497 | | - >>> s1.index.symmetric_difference(s2.index) |
498 | | - Int64Index([5, 1], dtype='int64') |
499 | | -
|
500 | | - You can set name of result Index. |
501 | | -
|
502 | | - >>> s1.index.symmetric_difference(s2.index, result_name='koalas') |
503 | | - Int64Index([5, 1], dtype='int64', name='koalas') |
504 | | -
|
505 | | - You can set sort to `True`, if you want to sort the resulting index. |
506 | | -
|
507 | | - >>> s1.index.symmetric_difference(s2.index, sort=True) |
508 | | - Int64Index([1, 5], dtype='int64') |
509 | | -
|
510 | | - You can also use the ``^`` operator: |
511 | | -
|
512 | | - >>> s1.index ^ s2.index |
513 | | - Int64Index([5, 1], dtype='int64') |
514 | | - """ |
515 | | - sdf_self = self._kdf._sdf.select(self._internal.index_scols) |
516 | | - sdf_other = other._kdf._sdf.select(other._internal.index_scols) |
517 | | - |
518 | | - sdf_symdiff = sdf_self.union(sdf_other) \ |
519 | | - .subtract(sdf_self.intersect(sdf_other)) |
520 | | - |
521 | | - if sort: |
522 | | - sdf_symdiff = sdf_symdiff.sort(self._internal.index_scols) |
523 | | - |
524 | | - internal = self._kdf._internal.copy(sdf=sdf_symdiff) |
525 | | - result = Index(DataFrame(internal)) |
526 | | - |
527 | | - if result_name: |
528 | | - result.name = result_name |
529 | | - |
530 | | - return result |
531 | | - |
532 | 467 | def __getattr__(self, item: str) -> Any: |
533 | 468 | if hasattr(_MissingPandasLikeIndex, item): |
534 | 469 | property_or_func = getattr(_MissingPandasLikeIndex, item) |
@@ -556,9 +491,6 @@ def __repr__(self): |
556 | 491 | def __iter__(self): |
557 | 492 | return _MissingPandasLikeIndex.__iter__(self) |
558 | 493 |
|
559 | | - def __xor__(self, other): |
560 | | - return self.symmetric_difference(other) |
561 | | - |
562 | 494 |
|
563 | 495 | class MultiIndex(Index): |
564 | 496 | """ |
@@ -717,88 +649,6 @@ def copy(self): |
717 | 649 | result = MultiIndex(ks.DataFrame(internal)) |
718 | 650 | return result |
719 | 651 |
|
720 | | - def symmetric_difference(self, other, result_name=None, sort=None): |
721 | | - """ |
722 | | - Compute the symmetric difference of two MultiIndex objects. |
723 | | -
|
724 | | - Parameters |
725 | | - ---------- |
726 | | - other : Index or array-like |
727 | | - result_name : list |
728 | | - sort : True or None, default None |
729 | | - Whether to sort the resulting index. |
730 | | - * True : Attempt to sort the result. |
731 | | - * None : Do not sort the result. |
732 | | -
|
733 | | - Returns |
734 | | - ------- |
735 | | - symmetric_difference : MiltiIndex |
736 | | -
|
737 | | - Notes |
738 | | - ----- |
739 | | - ``symmetric_difference`` contains elements that appear in either |
740 | | - ``idx1`` or ``idx2`` but not both. Equivalent to the Index created by |
741 | | - ``idx1.difference(idx2) | idx2.difference(idx1)`` with duplicates |
742 | | - dropped. |
743 | | -
|
744 | | - Examples |
745 | | - -------- |
746 | | - >>> midx1 = pd.MultiIndex([['lama', 'cow', 'falcon'], |
747 | | - ... ['speed', 'weight', 'length']], |
748 | | - ... [[0, 0, 0, 1, 1, 1, 2, 2, 2], |
749 | | - ... [0, 0, 0, 0, 1, 2, 0, 1, 2]]) |
750 | | - >>> midx2 = pd.MultiIndex([['koalas', 'cow', 'falcon'], |
751 | | - ... ['speed', 'weight', 'length']], |
752 | | - ... [[0, 0, 0, 1, 1, 1, 2, 2, 2], |
753 | | - ... [0, 0, 0, 0, 1, 2, 0, 1, 2]]) |
754 | | - >>> s1 = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], |
755 | | - ... index=midx1) |
756 | | - >>> s2 = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], |
757 | | - ... index=midx2) |
758 | | -
|
759 | | - >>> s1.index.symmetric_difference(s2.index) # doctest: +SKIP |
760 | | - MultiIndex([('koalas', 'speed'), |
761 | | - ( 'lama', 'speed')], |
762 | | - ) |
763 | | -
|
764 | | - You can set names of result Index. |
765 | | -
|
766 | | - >>> s1.index.symmetric_difference(s2.index, result_name=['a', 'b']) # doctest: +SKIP |
767 | | - MultiIndex([('koalas', 'speed'), |
768 | | - ( 'lama', 'speed')], |
769 | | - names=['a', 'b']) |
770 | | -
|
771 | | - You can set sort to `True`, if you want to sort the resulting index. |
772 | | -
|
773 | | - >>> s1.index.symmetric_difference(s2.index, sort=True) # doctest: +SKIP |
774 | | - MultiIndex([('koalas', 'speed'), |
775 | | - ( 'lama', 'speed')], |
776 | | - ) |
777 | | -
|
778 | | - You can also use the ``^`` operator: |
779 | | -
|
780 | | - >>> s1.index ^ s2.index # doctest: +SKIP |
781 | | - MultiIndex([('koalas', 'speed'), |
782 | | - ( 'lama', 'speed')], |
783 | | - ) |
784 | | - """ |
785 | | - sdf_self = self._kdf._sdf.select(self._internal.index_scols) |
786 | | - sdf_other = other._kdf._sdf.select(other._internal.index_scols) |
787 | | - |
788 | | - sdf_symdiff = sdf_self.union(sdf_other) \ |
789 | | - .subtract(sdf_self.intersect(sdf_other)) |
790 | | - |
791 | | - if sort: |
792 | | - sdf_symdiff = sdf_symdiff.sort(self._internal.index_scols) |
793 | | - |
794 | | - internal = self._kdf._internal.copy(sdf=sdf_symdiff) |
795 | | - result = MultiIndex(DataFrame(internal)) |
796 | | - |
797 | | - if result_name: |
798 | | - result.names = result_name |
799 | | - |
800 | | - return result |
801 | | - |
802 | 652 | def __getattr__(self, item: str) -> Any: |
803 | 653 | if hasattr(_MissingPandasLikeMultiIndex, item): |
804 | 654 | property_or_func = getattr(_MissingPandasLikeMultiIndex, item) |
|
0 commit comments