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/02 06:00:46 UTC

[GitHub] [spark] itholic commented on a change in pull request #33850: [SPARK-36531][SPARK-36515][PYTHON] Improve test coverage for data_type_ops/* and groupby.

itholic commented on a change in pull request #33850:
URL: https://github.com/apache/spark/pull/33850#discussion_r700769256



##########
File path: python/pyspark/pandas/data_type_ops/binary_ops.py
##########
@@ -100,7 +99,9 @@ def astype(self, index_ops: IndexOpsLike, dtype: Union[str, type, Dtype]) -> Ind
         if isinstance(dtype, CategoricalDtype):
             return _as_categorical_type(index_ops, dtype, spark_type)
         elif isinstance(spark_type, BooleanType):
-            return _as_bool_type(index_ops, dtype)
+            # Cannot cast binary to boolean in Spark.
+            # We should cast binary to str first, and cast it to boolean
+            return index_ops.astype(str).astype(bool)

Review comment:
       added!




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