ueshin commented on a change in pull request #33634:
URL: https://github.com/apache/spark/pull/33634#discussion_r682859453



##########
File path: python/pyspark/pandas/indexes/base.py
##########
@@ -2293,8 +2311,6 @@ def union(
         sdf_self = 
self._internal.spark_frame.select(self._internal.index_spark_columns)
         sdf_other = 
other_idx._internal.spark_frame.select(other_idx._internal.index_spark_columns)
         sdf = sdf_self.union(sdf_other.subtract(sdf_self))

Review comment:
       Could you try 
`sdf_self.unionAll(sdf_other).exceptAll(sdf_self.intersectAll(sdf_other))`?
   
   It seems working at least with the example above:
   
   ```py
   >>> ps_idx1 = ps.Index([1, 1, 1, 1, 1, 2, 2])
   >>> ps_idx2 = ps.Index([1, 1, 2, 2, 2, 2, 2])
   
   >>> ps_idx1.union(ps_idx2)
   Int64Index([1, 1, 1, 1, 1, 2, 2, 2, 2, 2], dtype='int64')
   >>> ps_idx1.to_pandas().union(ps_idx2.to_pandas())
   Int64Index([1, 1, 1, 1, 1, 2, 2, 2, 2, 2], dtype='int64')
   ```
   
   I haven't tried the other examples and I'm not sure how expensive this is, 
though.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to