Skip to content

[Python] Add timezone information when printing TimestampArray #39315

@AlenkaF

Description

@AlenkaF

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

# Adding timezone information in new line
>>> pa.array([0], pa.timestamp('s', tz='+02:00'))
<pyarrow.lib.TimestampArray object at 0x125319de0>
<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'))
<pyarrow.lib.TimestampArray object at 0x125319e40><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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions