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] Add support for cudf.Timestamp #16450

Closed

Conversation

Matt711
Copy link
Contributor

@Matt711 Matt711 commented Jul 31, 2024

Description

closes #12052 and closes #16420

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@Matt711 Matt711 added feature request New feature or request Python Affects Python cuDF API. non-breaking Non-breaking change cudf.pandas Issues specific to cudf.pandas labels Jul 31, 2024
@Matt711 Matt711 self-assigned this Jul 31, 2024
Copy link

copy-pr-bot bot commented Aug 7, 2024

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Matt711
Copy link
Contributor Author

Matt711 commented Aug 7, 2024

/ok to test

@Matt711
Copy link
Contributor Author

Matt711 commented Aug 15, 2024

/ok to test

@Matt711 Matt711 requested a review from mroeschke August 15, 2024 13:48
Copy link
Contributor Author

@Matt711 Matt711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the bulk of the changes are there. It still needs some tests.

cc. @mroeschke

raise NotImplementedError("The method 'ceil' is not implemented.")

@classmethod
def combine(cls, date, time):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Type the arguments

from cudf.core.scalar import Scalar


class Timestamp(Scalar):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if would be better to first get the implementations of cudf.Timestamp and cudf.Timedelta in and track their performance implications before replacing them throughout cudf (eg. here)

super().__init__(ts)

@property
def value(self) -> np.datetime64:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the host value just be a pandas.Timestamp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like there's a cudf.Scalar.value which cudf.Timestamp inherits. It returns a np.datetime64 object. But there's also pd.Timestamp.value which returns an integer.

I think your right thatcudf.Timestamp.value should return pd.Timestamp(super().value).value. And I'll a separate property for access to the scalar value (np.datetime64).

Copy link
Contributor Author

@Matt711 Matt711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ready for review soon after these comments are addressed and I add some tests.

python/cudf/cudf/core/timestamp.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/timestamp.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/timestamp.py Show resolved Hide resolved
super().__init__(ts)

@property
def value(self) -> np.datetime64:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like there's a cudf.Scalar.value which cudf.Timestamp inherits. It returns a np.datetime64 object. But there's also pd.Timestamp.value which returns an integer.

I think your right thatcudf.Timestamp.value should return pd.Timestamp(super().value).value. And I'll a separate property for access to the scalar value (np.datetime64).

python/cudf/cudf_pandas_tests/test_profiler.py Outdated Show resolved Hide resolved
@Matt711 Matt711 marked this pull request as ready for review September 5, 2024 20:42
@Matt711 Matt711 requested a review from a team as a code owner September 5, 2024 20:42
@Matt711
Copy link
Contributor Author

Matt711 commented Sep 16, 2024

/ok to test

**kwargs,
):
pd_ts_kwargs = {k: v for k, v in kwargs.items() if k != "dtype"}
ts = pd.Timestamp(*args, **pd_ts_kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you are constructing a pandas Timestamp here? Is it being done only for validation purposes?

@Matt711 Matt711 changed the base branch from branch-24.10 to branch-24.12 September 24, 2024 03:13
@Matt711
Copy link
Contributor Author

Matt711 commented Oct 7, 2024

I'd like to have some more offline discussion about the implementations of cudf.Timestamp and cudf.Timedelta before I proceed. Closing the PR for now.

@Matt711 Matt711 closed this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cudf.pandas Issues specific to cudf.pandas feature request New feature or request non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] Series.min returns np.datetime64 not pd.Timestamp in cudf.pandas [FEA] cudf.Timestamp
3 participants