ueshin commented on a change in pull request #33735: URL: https://github.com/apache/spark/pull/33735#discussion_r688689961
########## File path: python/pyspark/pandas/data_type_ops/datetime_ops.py ########## @@ -135,9 +136,7 @@ def astype(self, index_ops: IndexOpsLike, dtype: Union[str, type, Dtype]) -> Ind elif isinstance(spark_type, StringType): if isinstance(dtype, extension_dtypes): # seems like a pandas' bug? - scol = F.when(index_ops.spark.column.isNull(), str(pd.NaT)).otherwise( - index_ops.spark.column.cast(spark_type) - ) + return _as_string_type(index_ops, dtype) Review comment: I guess we can use `_as_string_type` more widely? ```py ... return _as_bool_type(index_ops, dtype) elif isinstance(spark_type, StringType): return _as_string_type(index_ops, dtype, null_str=str(pd.NaT)) else: ... ``` cc @xinrong-databricks -- 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