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



##########
File path: python/pyspark/pandas/data_type_ops/num_ops.py
##########
@@ -371,15 +384,7 @@ def isnull(self, index_ops: IndexOpsLike) -> IndexOpsLike:
 
     def astype(self, index_ops: IndexOpsLike, dtype: Union[str, type, Dtype]) 
-> IndexOpsLike:
         dtype, spark_type = pandas_on_spark_type(dtype)
-
-        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)
-        elif isinstance(spark_type, StringType):
-            return _as_string_type(index_ops, dtype, null_str=str(np.nan))
-        else:
-            return _as_other_type(index_ops, dtype, spark_type)
+        return _non_fractional_astype(index_ops, dtype, spark_type)

Review comment:
       Don't we need to check `index_ops.hasnans` here?

##########
File path: python/pyspark/pandas/data_type_ops/num_ops.py
##########
@@ -34,15 +34,29 @@
     _as_string_type,
 )
 from pyspark.pandas.spark import functions as SF
-from pyspark.pandas.typedef.typehints import extension_dtypes, 
pandas_on_spark_type
+from pyspark.pandas.typedef import extension_dtypes, pandas_on_spark_type
 from pyspark.sql import functions as F
 from pyspark.sql.column import Column
 from pyspark.sql.types import (
     BooleanType,
+    DataType,
     StringType,
 )
 
 
+def _non_fractional_astype(
+    index_ops: IndexOpsLike, dtype: Dtype, spark_type: DataType
+) -> IndexOpsLike:

Review comment:
       Nice!

##########
File path: python/pyspark/pandas/data_type_ops/num_ops.py
##########
@@ -34,15 +34,29 @@
     _as_string_type,
 )
 from pyspark.pandas.spark import functions as SF
-from pyspark.pandas.typedef.typehints import extension_dtypes, 
pandas_on_spark_type
+from pyspark.pandas.typedef import extension_dtypes, pandas_on_spark_type

Review comment:
       Why is this modified?




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

Reply via email to