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

[FEA] Implement DatetimeProperties.date #9877

Closed
charlesbluca opened this issue Dec 9, 2021 · 2 comments
Closed

[FEA] Implement DatetimeProperties.date #9877

charlesbluca opened this issue Dec 9, 2021 · 2 comments
Labels
feature request New feature or request

Comments

@charlesbluca
Copy link
Member

Is your feature request related to a problem? Please describe.
In Pandas, it is possible to extract the date from a column of datetime objects using the date attribute of the DatetimeProperties:

import cudf

gsr = cudf.Series(cudf.date_range("2000", freq='s', periods=6))
psr = gsr.to_pandas()

psr.dt.date
0    2000-01-01
1    2000-01-01
2    2000-01-01
3    2000-01-01
4    2000-01-01
5    2000-01-01
dtype: object

This attribute doesn't exist in cuDF's DatetimeProperties:

gsr.dt.date
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-16-53087fa7f6a3> in <module>
----> 1 gsr.dt.date

AttributeError: 'DatetimeProperties' object has no attribute 'date'

Describe the solution you'd like
It would be nice to have a date attribute for the DatetimeProperties to match up with the one in Pandas.

Describe alternatives you've considered
It is possible to compute roughly the same series using strftime:

gsr.dt.strftime("%Y-%m-%d")
0    2000-01-01
1    2000-01-01
2    2000-01-01
3    2000-01-01
4    2000-01-01
5    2000-01-01
dtype: object

I'm not sure if there's a more performant way to achieve this using _get_dt_field.

Additional context
This is coming up as a blocker for some datetime casting work in dask-contrib/dask-sql#343. If it is reasonably performant to use strftime here we can use that instead of date.

@charlesbluca charlesbluca added feature request New feature or request Needs Triage Need team to review and classify labels Dec 9, 2021
@beckernick
Copy link
Member

I believe this is a duplicate of #7880

@charlesbluca can we consolidate discussion in that issue?

@charlesbluca
Copy link
Member Author

Sure!

@bdice bdice removed the Needs Triage Need team to review and classify label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants