-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
API: offsets.Day is always calendar-day #61985
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
base: main
Are you sure you want to change the base?
Conversation
is stumping me. Who is our go-to person for debugging these? |
Still seeing
Tried building the docs locally and jinja2 is complaining |
Looks like there was even more whitespace I messed up. It's happy now. |
@@ -2763,7 +2768,10 @@ def _adjust_dates_anchored( | |||
if offset is not None: | |||
offset = offset.as_unit(unit) | |||
|
|||
freq_value = Timedelta(freq).as_unit(unit)._value | |||
if isinstance(freq, Day): |
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.
In #41943 I was hoping that if D
means calendar day, we wouldn't need to force to be a fixed frequency in resample
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.
yah i was hoping for this too but wasn't able to get it working. will give it another try after addressing other comments
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.
just double-checked. im pretty sure the place to change the treatment would be in _get_timestamp_range_edges a bit up the call stack. Changing that to have Day cases no longer go down the Tick route breaks test_resample_origin_with_day_freq_on_dst and test_resample_tz_localized2. it wasn't obvious that the "new" behavior was correct in those tests with that change. can you confirm?
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.
im pretty sure the place to change the treatment would be in _get_timestamp_range_edges
That makes sense to me, as I would expect us not to have to special case Day
anymore
test_resample_origin_with_day_freq_on_dst and test_resample_tz_localized2.
Mind showing an example of the new behavior based on those tests? I would expect breakage for these tests since D
changing to calendar day impacts the results around DST.
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.
Based on test_resample_tz_localized2:
idx = date_range("2001-09-20 15:59", "2001-09-20 16:00", freq="min", tz="Australia/Sydney")
s = Series([1, 2], index=idx)
result = s.resample("D", closed="right", label="right").mean()
ex_index = date_range("2001-09-21", periods=1, freq="D", tz="Australia/Sydney")
expected = Series([1.5], index=ex_index)
tm.assert_series_equal(result, expected) # Fails with actual result being...
ex_index = pd.date_range("2001-09-20", "2001-09-21", tz="Australia/Sydney", freq="D")
expected = Series([np.nan, 1.5], index=ex_index)
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Alternative to #55502 discussed at last week's dev meeting. This allows TimedeltaIndex.freq to be a
Day
even though it is not a Tick.