apache / apache/arrow

DOC: to_pylist returns a pandas.Timestamp instead of datetime.datetime when the type is timestamp[ns]

Open
#34,614 3 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 18h
Merged PRs (30d)
91

Description

### Describe the enhancement requested

```
In [2]: import pyarrow as pa; from datetime import datetime

In [4]: pa.array([datetime(2023, 1, 1)], type=pa.timestamp("ns")).to_pylist()
Out[4]: [Timestamp('2023-01-01 00:00:00')]
```

From the docs, I assumed `Convert to a list of native Python objects.` means I should always expected a `datetime.datetime`object, but since I suppose it cannot handle nanosecond components this method returns a `pandas.Timestamp` when the unit is `"ns"`

### Component(s)

Python

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the pa.array(..., type=pa.timestamp("ns")).to_pylist() example from the issue and inspect the Python conversion path for timestamp[ns] values. Check the documentation wording for to_pylist and existing tests around timestamp conversion; done means the returned type and its documentation agree for nanosecond timestamps.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.