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

Allow GreaterThan constraint to work with timestamp #597

Merged
merged 3 commits into from
Sep 22, 2021

Conversation

katxiao
Copy link
Contributor

@katxiao katxiao commented Sep 21, 2021

Currently, the GreaterThan constraint crashes when passed a pd.Timestamp value. Convert the timestamp to a datetime so that it is able to be compared.

Resolves #596

@katxiao katxiao requested review from a team, sarahmish and csala and removed request for a team and sarahmish September 21, 2021 21:55
@katxiao katxiao marked this pull request as ready for review September 21, 2021 21:57
@katxiao katxiao requested a review from a team as a code owner September 21, 2021 21:57
Copy link
Contributor

@csala csala left a comment

Choose a reason for hiding this comment

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

LGTM!

Just a comment about adding blank lines.

@@ -320,10 +320,14 @@ def _validate_inputs(cls, low, high, scalar, drop):
cls._validate_drop(scalar, drop)
high = cls._validate_scalar(scalar_column=low, column_names=high, scalar=scalar)
constraint_columns = tuple(high)
if isinstance(low, pd.Timestamp):
low = low.to_datetime64()
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor detail, can we add a blank line below this one?

elif scalar == 'high':
cls._validate_drop(scalar, drop)
low = cls._validate_scalar(scalar_column=high, column_names=low, scalar=scalar)
constraint_columns = tuple(low)
if isinstance(high, pd.Timestamp):
high = high.to_datetime64()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Contributor

@amontanez24 amontanez24 left a comment

Choose a reason for hiding this comment

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

:shipit:

@katxiao katxiao merged commit 914f6ea into master Sep 22, 2021
@katxiao katxiao deleted the sdv-issue-596-greater-than-datetime branch September 22, 2021 18:37
@katxiao katxiao modified the milestone: 0.12.1 Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GreaterThan constraint raises TypeError when using datetime
3 participants