-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: resample with TimedeltaIndex, fenceposts are off #22488
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ | |
from pandas.compat import range, lrange, zip, OrderedDict | ||
from pandas.errors import UnsupportedFunctionCall | ||
import pandas.tseries.offsets as offsets | ||
from pandas.tseries.frequencies import to_offset | ||
from pandas.tseries.offsets import Minute, BDay | ||
|
||
from pandas.core.groupby.groupby import DataError | ||
|
@@ -626,12 +625,7 @@ def test_asfreq(self, series_and_frame, freq): | |
obj = series_and_frame | ||
|
||
result = obj.resample(freq).asfreq() | ||
if freq == '2D': | ||
new_index = obj.index.take(np.arange(0, len(obj.index), 2)) | ||
new_index.freq = to_offset('2D') | ||
else: | ||
new_index = self.create_index(obj.index[0], obj.index[-1], | ||
freq=freq) | ||
new_index = self.create_index(obj.index[0], obj.index[-1], freq=freq) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The case noted here is covered by this test. However, it used to produce the incorrect index so tests were passing (which is incorrect). Here is the old expected index for TDI:
|
||
expected = obj.reindex(new_index) | ||
assert_almost_equal(result, expected) | ||
|
||
|
@@ -2932,6 +2926,17 @@ def test_resample_with_nat(self): | |
freq='1S')) | ||
assert_frame_equal(result, expected) | ||
|
||
def test_resample_as_freq_with_subperiod(self): | ||
# GH 13022 | ||
index = timedelta_range('00:00:00', '00:10:00', freq='5T') | ||
df = DataFrame(data={'value': [1, 5, 10]}, index=index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add the other example in the OP here as well (or is it too duplicative)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other example is duplicative of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, no that is fine |
||
result = df.resample('2T').asfreq() | ||
expected_data = {'value': [1, np.nan, np.nan, np.nan, np.nan, 10]} | ||
expected = DataFrame(data=expected_data, | ||
index=timedelta_range('00:00:00', | ||
'00:10:00', freq='2T')) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
class TestResamplerGrouper(object): | ||
|
||
|
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.
can you add a comment here (and maybe refresh the comment in same method for DTI resampling)
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.
@jreback
Could you please clarify how I should refresh the comment for DTI? What should be instead of
adjust our binner when upsampling
?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.
add a comment on why we are NOT adjusting anything here for TDI (e.g. just returning it directly). basically explain why DTI but not TDI needs adjustment
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 a reminder: here is why we adjust a binner #10885