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/03 05:18:37 UTC

[GitHub] [spark] xinrong-databricks commented on a change in pull request #34776: [SPARK-37512][PYTHON] Support TimedeltaIndex creation (from Series/Index) and TimedeltaIndex.astype

xinrong-databricks commented on a change in pull request #34776:
URL: https://github.com/apache/spark/pull/34776#discussion_r761652551



##########
File path: python/pyspark/pandas/data_type_ops/timedelta_ops.py
##########
@@ -26,3 +42,19 @@ class TimedeltaOps(DataTypeOps):
     @property
     def pretty_name(self) -> str:
         return "timedelta"
+
+    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):
+            raise TypeError("cannot astype a datetimelike from [timedelta64[ns]] to [bool]")

Review comment:
       Certainly, will adjust it in https://github.com/apache/spark/pull/34787, thanks!




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