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/12/01 23:47:34 UTC

[GitHub] [spark] ueshin commented on a change in pull request #34509: [SPARK-34521][PYTHON][SQL] Fix spark.createDataFrame when using pandas with StringDtype

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



##########
File path: python/pyspark/sql/pandas/serializers.py
##########
@@ -169,6 +169,8 @@ def create_array(s, t):
             elif is_categorical_dtype(s.dtype):
                 # Note: This can be removed once minimum pyarrow version is >= 0.16.1
                 s = s.astype(s.dtypes.categories.dtype)
+            elif t is not None and pa.types.is_string(t):
+                s = s.astype(str)

Review comment:
       I think it's fine if the `df`'s data type is `LongType` for `dtype="Int64"` because `df.toPandas()` won't keep the extension dtypes.
   So the dtype of `df.toPandas()` will be `int64`, or `float64` if containing `None`.




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