apache / apache/arrow

[Python] Add timezone information when printing TimestampArray

Open
#39,315 12 comments 1 reaction 0 assignees View on GitHub
Component: Python Component: R Status: needs champion Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the enhancement requested

`PrettyPrint` for `Timestamp` is currently printing values in UTC even when the timezone is defined. This can get confusing and there is a PR open with a simple fix of adding "Z" to the end of the string in case timezone is defined:
https://github.com/apache/arrow/pull/39272

This way we can at least see which tz is the data printed in.

It would also be good to add timezone information when printing the array, for example:

```python
# Adding timezone information in new line
>>> pa.array([0], pa.timestamp('s', tz='+02:00'))

[
1970-01-01 00:00:00Z
]

# Or at the end of first line (not very clear in my opinion)
>>> pa.array([0], pa.timestamp('s'))

[
1970-01-01 00:00:00
]
```

In Python this can be done by adding a separate `__repr__` to `TimestampArray` class.

Would something similar also be needed for R or is timezone information available when printing an Array? cc @paleolimbot

### Component(s)

Python, R

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.