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] Series datetime is_leap_year #8677

Closed
beckernick opened this issue Jul 7, 2021 · 1 comment · Fixed by #8736
Closed

[FEA] Series datetime is_leap_year #8677

beckernick opened this issue Jul 7, 2021 · 1 comment · Fixed by #8736
Assignees
Labels
feature request New feature or request Python Affects Python cuDF API.

Comments

@beckernick
Copy link
Member

beckernick commented Jul 7, 2021

For feature engineering tasks, I'd like to be able to determine whether a datetime occurs in a leap year, like I can in pandas.

import pandas as pds = pd.Series(["2021-02-27", "2020-04-01"], dtype="datetime64[ms]")
s.dt.is_leap_year
0    False
1     True
dtype: bool
@beckernick beckernick added feature request New feature or request Python Affects Python cuDF API. labels Jul 7, 2021
@isVoid
Copy link
Contributor

isVoid commented Jul 9, 2021

@jrhemstad do we want to support this in libcudf?

[EDIT] argument for supporting in libcudf: doing this in python will probably be implemented by binops which has quite some overhead.

@isVoid isVoid self-assigned this Jul 9, 2021
rapids-bot bot pushed a commit that referenced this issue Jul 13, 2021
Part 1 of #8677 

This PR adds `datetime::is_leap_year`. The function returns `true` for datetime column rows with leap year; `false` for rows with non leap years, and `null` for null rows.

Authors:
  - Michael Wang (https://github.com/isVoid)

Approvers:
  - Mark Harris (https://github.com/harrism)
  - Karthikeyan (https://github.com/karthikeyann)

URL: #8711
@beckernick beckernick added this to the Time Series Analysis milestone Jul 14, 2021
rapids-bot bot pushed a commit that referenced this issue Jul 14, 2021
Closes #8677 

This PR adds `is_leap_year` for `cudf.Series.dt` and `cudf.DatetimeIndex`. Nulls in time series are treated as `NaT`s in Pandas time series and is mapped to `False` in this operation. E.g.

```python
>>> s = cudf.Series(['2020-01-01 08:00:00', None, '2021-12-31 09:00:00'], dtype='datetime64[ns]')
>>> s.dt.is_leap_year
0     True
1    False
2    False
dtype: bool
```

Authors:
  - Michael Wang (https://github.com/isVoid)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)

URL: #8736
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