nicolasazrak commented on a change in pull request #34509:
URL: https://github.com/apache/spark/pull/34509#discussion_r760648330
##########
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:
@ueshin Makes a lot of sense. I wasn't aware this was a problem for
other dtypes. Removing the mask works, but writing a quick test:
```python
with self.sql_conf({"spark.sql.execution.arrow.pyspark.enabled": True}):
pandas_df = pd.DataFrame({"col": [1, 2, 3, None]}, dtype="Int64")
df = self.spark.createDataFrame(pandas_df)
assert_frame_equal(pandas_df, df.toPandas())
```
fails with:
```
Attribute "dtype" are different
[left]: Int64
[right]: float64
```
I'm going to take a look where the conversion is failing.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]