Skip to content

ENH: Add dtype_backend parameter to to_datetime #53952

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

Open
1 of 3 tasks
wirable23 opened this issue Jun 30, 2023 · 7 comments
Open
1 of 3 tasks

ENH: Add dtype_backend parameter to to_datetime #53952

wirable23 opened this issue Jun 30, 2023 · 7 comments
Labels
Datetime Datetime data dtype Enhancement

Comments

@wirable23
Copy link

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

>>> a = pd.Series([4194304], dtype="int64[pyarrow]")
>>> pd.to_datetime(a).dtype
dtype('<M8[ns]')
>>>

In the above example, passing in a pyarrow backed series to to_datetime returns a numpy backed series, in to_numeric, there's a dtype_backend parameter that allows preserving of pyarrow dtypes, it would be nice to have the same option in to_datetime.

Feature Description

Same way as in to_numeric, adding a dtype_backend parameter.

Alternative Solutions

N/A

Additional Context

No response

@wirable23 wirable23 added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 30, 2023
@phofl
Copy link
Member

phofl commented Jul 5, 2023

Yep this sounds good. Same as for to_numeric basically. Pinging @MarcoGorelli

@MarcoGorelli
Copy link
Member

sounds good - interested in submitting a pull request @wirable23 ?

@MarcoGorelli MarcoGorelli added Datetime Datetime data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 6, 2023
@wirable23
Copy link
Author

@MarcoGorelli yes! The issue I was facing was that I didn't see arrow compute functions for some functionality of to_datetime, for example, pyarrow does not seem to have a compute function for creating datetimes from day month year components. Also, pyarrow does not support casting floating points to datetimes but there might be some other compute function that can be used.

@lithomas1 lithomas1 self-assigned this Oct 9, 2023
@ruimamaral
Copy link
Contributor

@lithomas1 @wirable23 I see there haven't been any updates to this issue in a while.
If you're both okay with it, I would like to implement this functionality.
Thanks!

@lithomas1 lithomas1 removed their assignment Apr 29, 2024
@lithomas1
Copy link
Member

Go for it.

@ruimamaral
Copy link
Contributor

take

@ruimamaral
Copy link
Contributor

I initially assigned myself as I thought I had a good idea of how this should be implemented, however after looking more deeply into to_datetime and pyarrow, I realize that I might've bit off more than I could chew...

My main issue is trying to figure out the best places to convert the dates between their numpy and pyarrow counterparts.
Since I don't feel certain about the full implementation details, I think it would be best to leave this one out to someone more familiar with pyarrow and this part of the codebase.

Therefore, I will be unassigning myself from this issue.

I apologize for any inconvenience caused!

@ruimamaral ruimamaral removed their assignment May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement
Projects
None yet
Development

No branches or pull requests

5 participants