xinrong-databricks commented on a change in pull request #33911:
URL: https://github.com/apache/spark/pull/33911#discussion_r704796337



##########
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:
       How do you think about the code block below?
   ```py
   def _is_valid_for_logical_operator(right: Any) -> bool:
       from pyspark.pandas.base import IndexOpsMixin
   
       return (
           isinstance(right, IndexOpsMixin)
           and (
               isinstance(right.spark.data_type, BooleanType)
               or isinstance(right.spark.data_type, IntegralType)
           )
           or isinstance(right, (int, bool))
       )
   ```
   
   IndexOpsMixin provides a unified interface for Series and Index.
   DataTypeOps aims to make operations of Series and Index data-type-based.
   We may access the DataTypeOps from the property `_dtype_op` of IndexOpsMixin.
   Hope that makes sense to you. Let me know if you have any other questions :).




-- 
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