Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mroeschke opened this issue Mar 17, 2023 · 2 comments

Comments

@mroeschke
Copy link
Contributor

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.datetimeobject, but since I suppose it cannot handle nanosecond components this method returns a pandas.Timestamp when the unit is "ns"

Component(s)

Python

@jorisvandenbossche
Copy link
Member

but since I suppose it cannot handle nanosecond components this method returns a pandas.Timestamp when the unit is "ns"

That's a correct assumption. I don't think there is anything to do about that? (except for raising an error instead, given that datetime.datetime can't handle nanoseconds)

@mroeschke
Copy link
Contributor Author

Yeah would be good to document this behavior. Or as you mentioned potentially raising. Or warning that nanosecond components would be dropped if storing in a datetime.datetime. I don't have a strong preference either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants