From 7a470ffd2ef543d996550cd0867f67a99ddef46e Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Thu, 11 May 2023 17:47:32 -0400 Subject: [PATCH] Fix repr --- python/cudf/cudf/core/column/datetime.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/column/datetime.py b/python/cudf/cudf/core/column/datetime.py index bd6c933078f..92bb5abd8ac 100644 --- a/python/cudf/cudf/core/column/datetime.py +++ b/python/cudf/cudf/core/column/datetime.py @@ -565,8 +565,8 @@ def to_pandas( ) def to_arrow(self): - return self._local_time.to_arrow().cast( - pa.timestamp(self.dtype.unit, str(self.dtype.tz)) + return pa.compute.assume_timezone( + self._local_time.to_arrow(), str(self.dtype.tz) ) @property @@ -593,6 +593,18 @@ def as_string_column( ) -> "cudf.core.column.StringColumn": return self._local_time.as_string_column(dtype, format, **kwargs) + def __repr__(self): + # Arrow prints the UTC timestamps, but we want to print the + # local timestamps: + arr = self._local_time.to_arrow().cast( + pa.timestamp(self.dtype.unit, str(self.dtype.tz)) + ) + return ( + f"{object.__repr__(self)}\n" + f"{arr.to_string()}\n" + f"dtype: {self.dtype}" + ) + def infer_format(element: str, **kwargs) -> str: """