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] Support series.dt.round and DatetimeIndex.round operation #9652

Closed
mayankanand007 opened this issue Nov 10, 2021 · 0 comments · Fixed by #9820
Closed

[FEA] Support series.dt.round and DatetimeIndex.round operation #9652

mayankanand007 opened this issue Nov 10, 2021 · 0 comments · Fixed by #9820
Assignees
Labels
feature request New feature or request Python Affects Python cuDF API.

Comments

@mayankanand007
Copy link
Contributor

mayankanand007 commented Nov 10, 2021

Is your feature request related to a problem? Please describe.
Support for ceil was added in #8942 and floor in #9571 for a Series.dt column type. #9554 addresses adding support for ceil and floor for a DatetimeIndex column. Once we are able to support ceil and floor on columns of type datetime64[ns], it would be great to add support for round operation as well.

This can eventually be followed by issue #9561.

Describe the solution you'd like
Series.dt.round

>>> rng = pandas.date_range('1/1/2018 11:59:00', periods=3, freq='min')
>>> cudf.Series(rng).dt.round("H")
0   2018-01-01 12:00:00
1   2018-01-01 12:00:00
2   2018-01-01 12:00:00
dtype: datetime64[ns]

DatetimeIndex.round

>>> rng = cudf.Index(pd.date_range('1/1/2018 11:59:00', periods=3, freq='min'))
>>> rng.round('H')
DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
               '2018-01-01 12:00:00'],
              dtype='datetime64[ns]', freq=None)

Additional context
https://pandas.pydata.org/docs/reference/api/pandas.Series.dt.round.html
https://pandas.pydata.org/docs/reference/api/pandas.DatetimeIndex.round.html?#pandas-datetimeindex-round

@mayankanand007 mayankanand007 added feature request New feature or request Needs Triage Need team to review and classify labels Nov 10, 2021
@beckernick beckernick added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Nov 10, 2021
@beckernick beckernick added this to the Time Series Analysis milestone Nov 10, 2021
@mayankanand007 mayankanand007 self-assigned this Nov 17, 2021
@mayankanand007 mayankanand007 changed the title [FEA] Support round operation on datetime64[ns] datatypes [FEA] Support series.dt.round operation Dec 2, 2021
@mayankanand007 mayankanand007 changed the title [FEA] Support series.dt.round operation [FEA] Support series.dt.round and DatetimeIndex.round operation Dec 2, 2021
rapids-bot bot pushed a commit that referenced this issue Dec 10, 2021
This PR fixes #9652, by adding support for doing `round` operation on `dtaetime64[ns]` types, which is essentially supporting `series.dt.round` and `DatetimeIndex.round`.

In addition to this, we move the round implementation that is currently there from `Frame` to `IndexedFrame` as `pd.Index` doesn't support `round`. This is why we move this implementation to `IndexedFrame`, and add the code specifically for `DatetimeIndex` (for this PR), so as to avoid having a round method for another index types.

Authors:
  - Mayank Anand (https://github.com/mayankanand007)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #9820
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 Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants