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

BUG: loffset has no effect when passing in a numpy.timedelta64 #22482

Merged
merged 1 commit into from
Sep 4, 2018

Conversation

discort
Copy link
Contributor

@discort discort commented Aug 23, 2018

@@ -365,8 +365,9 @@ def _apply_loffset(self, result):
the result of resample
"""

loffset_types = (DateOffset, timedelta, np.timedelta64)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

np.timedelta64 is not the instance of timedelta

@TomAugspurger
Copy link
Contributor

restarted the failed travis worker.

@TomAugspurger
Copy link
Contributor

Could you add a release not in 0.24.0.txt?

@codecov
Copy link

codecov bot commented Aug 23, 2018

Codecov Report

Merging #22482 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22482      +/-   ##
==========================================
+ Coverage   92.04%   92.04%   +<.01%     
==========================================
  Files         169      169              
  Lines       50787    50787              
==========================================
+ Hits        46745    46746       +1     
+ Misses       4042     4041       -1
Flag Coverage Δ
#multiple 90.45% <ø> (ø) ⬆️
#single 42.29% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/resample.py 96.13% <ø> (ø) ⬆️
pandas/util/_depr_module.py 67.44% <0%> (+2.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db97089...4db1e81. Read the comment docs.

@pytest.mark.parametrize('loffset', [timedelta(minutes=1),
'1min', Minute(1),
np.timedelta64(1, 'm')])
def test_resample_loffset(self, loffset):
Copy link
Member

Choose a reason for hiding this comment

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

Can we put a comment referencing the issue next to the relevant input value to loffset?

@gfyoung gfyoung added Bug Resample resample method labels Aug 25, 2018
@discort discort force-pushed the numpy_timedelta_loffset branch 2 times, most recently from 7e3b383 to 10a28f5 Compare August 28, 2018 13:44
@@ -703,6 +703,7 @@ Groupby/Resample/Rolling
- Multiple bugs in :func:`pandas.core.Rolling.min` with ``closed='left'` and a
datetime-like index leading to incorrect results and also segfault. (:issue:`21704`)
- Bug in :meth:`Resampler.apply` when passing postiional arguments to applied func (:issue:`14615`).
- Bug in :meth:`Series.resample` when passing numpy.timedelta64 to `loffset` kwarg (:issue:`7687`).
Copy link
Contributor

Choose a reason for hiding this comment

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

double backticks around numpy.timedelta64

needs_offset = (
isinstance(self.loffset, (DateOffset, timedelta)) and
Copy link
Contributor

Choose a reason for hiding this comment

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

go ahead and inlinethese (add an overall comment if you would)

cc @jbrockmendel we should define scalar function helpers for this as we repeat lots of this in ops....

@@ -1173,27 +1173,20 @@ def test_resample_frame_basic(self):
df.resample('M', kind='period').mean()
df.resample('W-WED', kind='period').mean()

def test_resample_loffset(self):
@pytest.mark.parametrize('loffset', [timedelta(minutes=1),
Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to use hypothesis would be great here :> (can be followup, not sure how easy)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jreback

There are no many examples in pandas codebase how to use hypothesis. Furthermore, I know only 4 cases which need to test: timedelta(minutes=1), '1min', Minute(1), np.timedelta64(1, 'm'). Did I miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ping @jreback

@jreback jreback added this to the 0.24.0 milestone Aug 29, 2018
@jreback jreback merged commit 45b4957 into pandas-dev:master Sep 4, 2018
@jreback
Copy link
Contributor

jreback commented Sep 4, 2018

thanks @discort

aeltanawy pushed a commit to aeltanawy/pandas that referenced this pull request Sep 20, 2018
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Resample resample method
Projects
None yet
Development

Successfully merging this pull request may close these issues.

loffset has no effect when passing in a numyp.timedelta64
4 participants