From c2bb860e4b323d1f9efd593938fef3372f36bdef Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Thu, 7 Mar 2024 09:35:10 -1000 Subject: [PATCH] Don't override to_pandas for Datelike columns (#15167) `pandas.Series(pyarrow.array)` is first interpreted as an object data type since pandas doesn't know how to handle pyarrow arrays yet which is bad. Additionally if pyarrow becomes required in pandas this may have different behavior in the future. I think the linked issues might be outdated and we can rely on pyarrow's `to_pandas` Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/cudf/pull/15167 --- python/cudf/cudf/core/column/datetime.py | 27 ----------------------- python/cudf/cudf/core/column/timedelta.py | 27 ----------------------- 2 files changed, 54 deletions(-) diff --git a/python/cudf/cudf/core/column/datetime.py b/python/cudf/cudf/core/column/datetime.py index 85f07064c97..9a5d9dcd47a 100644 --- a/python/cudf/cudf/core/column/datetime.py +++ b/python/cudf/cudf/core/column/datetime.py @@ -313,33 +313,6 @@ def dayofyear(self) -> ColumnBase: def day_of_year(self) -> ColumnBase: return self.get_dt_field("day_of_year") - def to_pandas( - self, - *, - index: Optional[pd.Index] = None, - nullable: bool = False, - arrow_type: bool = False, - ) -> pd.Series: - if arrow_type and nullable: - raise ValueError( - f"{arrow_type=} and {nullable=} cannot both be set." - ) - elif nullable: - raise NotImplementedError(f"{nullable=} is not implemented.") - elif arrow_type: - return pd.Series( - pd.arrays.ArrowExtensionArray(self.to_arrow()), index=index - ) - else: - # `copy=True` workaround until following issue is fixed: - # https://issues.apache.org/jira/browse/ARROW-9772 - return pd.Series( - self.to_arrow(), - copy=True, - dtype=self.dtype, - index=index, - ) - @property def values(self): """ diff --git a/python/cudf/cudf/core/column/timedelta.py b/python/cudf/cudf/core/column/timedelta.py index ee326b254b9..0d24e8e5120 100644 --- a/python/cudf/cudf/core/column/timedelta.py +++ b/python/cudf/cudf/core/column/timedelta.py @@ -146,33 +146,6 @@ def to_arrow(self) -> pa.Array: null_count=self.null_count, ) - def to_pandas( - self, - *, - index: Optional[pd.Index] = None, - nullable: bool = False, - arrow_type: bool = False, - ) -> pd.Series: - # `copy=True` workaround until following issue is fixed: - # https://issues.apache.org/jira/browse/ARROW-9772 - if arrow_type and nullable: - raise ValueError( - f"{arrow_type=} and {nullable=} cannot both be set." - ) - elif nullable: - raise NotImplementedError(f"{nullable=} is not implemented.") - elif arrow_type: - return pd.Series( - pd.arrays.ArrowExtensionArray(self.to_arrow()), index=index - ) - else: - return pd.Series( - self.to_arrow(), - copy=True, - dtype=self.dtype, - index=index, - ) - def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: reflect, op = self._check_reflected_op(op) other = self._wrap_binop_normalization(other)