-
Notifications
You must be signed in to change notification settings - Fork 879
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
Update DateToHoliday and DistanceToHoliday primitives to work with timezone-aware inputs #2056
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2056 +/- ##
=======================================
Coverage 99.20% 99.20%
=======================================
Files 143 143
Lines 16540 16554 +14
=======================================
+ Hits 16408 16422 +14
Misses 132 132
Continue to review full report at Codecov.
|
@@ -201,7 +201,7 @@ def distance_to_holiday(x): | |||
df["x_index"] = df.index # store original index as a column | |||
df = df.dropna() | |||
df = df.sort_values("date") | |||
df.date = df.date.dt.normalize() | |||
df.date = df.date.dt.normalize().dt.date.astype("datetime64[ns]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to normalize if we are also extracting the date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the normalize calls aren't necessary anymore. Removed. Also updated to (I think) improve readability of these lines a little bit.
), | ||
"non_timezone_aware_no_time": pd.date_range("2018-07-03", periods=3), | ||
"timezone_aware_with_time": pd.date_range( | ||
"2018-07-03 09:00", periods=3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we test with times where if converted to UTC, some times would change dates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
This PR updates the
DateToHoliday
andDistanceToHoliday
primitives to work with timezone-aware inputs and adds new tests to verify the correct answer is returned.