You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/09/08 04:28:53 UTC

[GitHub] [spark] dgd-contributor commented on a change in pull request #33911: [SPARK-36653][PYTHON] implement Series.__xor__ and Series.__rxor__

dgd-contributor commented on a change in pull request #33911:
URL: https://github.com/apache/spark/pull/33911#discussion_r704017833



##########
File path: python/pyspark/pandas/data_type_ops/boolean_ops.py
##########
@@ -248,6 +249,30 @@ def and_func(left: Column, right: Any) -> Column:
 
             return column_op(and_func)(left, right)
 
+    def __xor__(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
+        _sanitize_list_like(right)
+        if isinstance(right, IndexOpsMixin) and isinstance(right.dtype, extension_dtypes):
+            return right.__xor__(left)
+        elif (
+            isinstance(right, int)
+            or (hasattr(right, "dtype") and np.issubdtype(right.dtype, int))
+            or isinstance(right, bool)
+            or (hasattr(right, "dtype") and right.dtype == "bool")

Review comment:
       Thank you
   Yeah, they have same result. But it throw "Circular import" when I try to extract that  ```elif```  to ```data_type_ops/base.py```.  I do not understand ```IndexOpsMinx```, I am appreciated if you could explain it and the better point. I deduplicated code. Could you take another look?

##########
File path: python/pyspark/pandas/data_type_ops/num_ops.py
##########
@@ -181,6 +181,39 @@ class IntegralOps(NumericOps):
     LongType, IntegerType, ByteType and ShortType.
     """
 
+    def __xor__(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
+        _sanitize_list_like(right)
+
+        right_is_boolean = (
+            True
+            if isinstance(right, bool) or (hasattr(right, "dtype") and right.dtype == "bool")
+            else False
+        )
+
+        if isinstance(right, IndexOpsMixin) and isinstance(right.dtype, extension_dtypes):
+            return right.__xor__(left)
+        elif (

Review comment:
       thanks, deduplicated.




-- 
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-unsubscribe@spark.apache.org

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



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