Skip to content

Commit

Permalink
Fix repr
Browse files Browse the repository at this point in the history
  • Loading branch information
shwina committed May 11, 2023
1 parent 40fad81 commit 7a470ff
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions python/cudf/cudf/core/column/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
"""
Expand Down

0 comments on commit 7a470ff

Please sign in to comment.