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

issue #27642 - timedelta merge asof with tolerance #27650

Merged
merged 25 commits into from Aug 22, 2019
Merged

issue #27642 - timedelta merge asof with tolerance #27650

merged 25 commits into from Aug 22, 2019

Conversation

ianzur
Copy link
Contributor

@ianzur ianzur commented Jul 29, 2019

@pep8speaks
Copy link

pep8speaks commented Jul 29, 2019

Hello @ianzur! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-22 11:36:23 UTC

@ianzur
Copy link
Contributor Author

ianzur commented Jul 29, 2019

My first PR, please be gentle.

@TomAugspurger TomAugspurger added this to the 0.25.1 milestone Jul 29, 2019
@TomAugspurger TomAugspurger added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timedelta Timedelta data type labels Jul 29, 2019
Copy link
Contributor

@TomAugspurger TomAugspurger left a 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 release note to doc/source/whatsnew/v0.25.1.rst?

We'll also want a test ensuring this continues to work in the future. Can you simplify your example from #27642 and make it a unit test? Make sure you include a reference to the GitHub issue in a comment in the test.

pandas/core/reshape/merge.py Outdated Show resolved Hide resolved
is_datetime64_dtype(lt)
or is_datetime64tz_dtype(lt)
or is_timedelta64_dtype(lt)
):
if not isinstance(self.tolerance, Timedelta):
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be if not isinstance(self.tolerance, datetime.timedelta) so users can pass datetime.timedelta objects. If you could add a test case for that situation that'd be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see commit "mroeschke: this test is for you 🚀"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the test fails

Copy link
Contributor Author

@ianzur ianzur Jul 30, 2019

Choose a reason for hiding this comment

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

I think we'll need a different PR for this test I think, it fails at this conversion check.

# initial type conversion as needed
if needs_i8_conversion(left_values):
left_values = left_values.view("i8")
right_values = right_values.view("i8")
if tolerance is not None:
tolerance = tolerance.value

With tolerance = datetime.timedelta -> ERROR: has no attribute "value"

Copy link
Contributor Author

@ianzur ianzur Jul 30, 2019

Choose a reason for hiding this comment

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

datetime.timedelta objects do not have nanoseconds like pd.Timedelta

Another check and conversion is necessary to convert datetime.timedelta correctly to nanoseconds similarly to pd.Timedelta.value

Copy link
Member

Choose a reason for hiding this comment

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

Okay thanks for investigating. Yes, I'd be great to address in another issues/PR.

doc/source/whatsnew/v0.25.1.rst Outdated Show resolved Hide resolved
pandas/tests/reshape/merge/test_merge_asof.py Outdated Show resolved Hide resolved
@ianzur
Copy link
Contributor Author

ianzur commented Aug 8, 2019

Does anyone understand why my test fails in python3.5?

@WillAyd
Copy link
Member

WillAyd commented Aug 8, 2019 via email

@ianzur ianzur closed this Aug 9, 2019
@ianzur ianzur reopened this Aug 9, 2019
@TomAugspurger
Copy link
Contributor

@ianzur you may want to set up a 3.5 env locally for testing that. conda env create -n pandas-azure-35-compat -f ci/deps/azure-35-compat.yaml

Timedelta("1day"),
pytest.param(
datetime.timedelta(days=1),
marks=pytest.mark.xfail(reason="not implemented", strict=True),
Copy link
Contributor

Choose a reason for hiding this comment

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

@ianzur Do we have an open issue to implement this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, not that I know of.

@TomAugspurger TomAugspurger merged commit def01cf into pandas-dev:master Aug 22, 2019
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Aug 22, 2019
@TomAugspurger
Copy link
Contributor

TomAugspurger commented Aug 22, 2019 via email

@ianzur
Copy link
Contributor Author

ianzur commented Aug 22, 2019 via email

galuhsahid pushed a commit to galuhsahid/pandas that referenced this pull request Aug 25, 2019
galuhsahid added a commit to galuhsahid/pandas that referenced this pull request Aug 25, 2019
* master: (40 commits)
  DOC: Fix GL01 and GL02 errors in the docstrings (pandas-dev#27988)
  Remove Encoding of values in char** For Labels (pandas-dev#27618)
  TYPING: more type hints for io.formats.printing (pandas-dev#27765)
  TST: fix compression tests when run without virtualenv/condaenv (pandas-dev#28051)
  DOC: Start 0.25.2 (pandas-dev#28111)
  DOC: Fix docstrings lack of punctuation (pandas-dev#28031)
  DOC: Remove alias for numpy.random.randn from the docs (pandas-dev#28082)
  DOC: update GroupBy.head()/tail() documentation (pandas-dev#27844)
  BUG: timedelta merge asof with tolerance (pandas-dev#27650)
  BUG: Series.rename raises error on values accepted by Series construc… (pandas-dev#27814)
  Preserve index when setting new column on empty dataframe. (pandas-dev#26471)
  BUG: Fixed groupby quantile for listlike q (pandas-dev#27827)
  BUG: iter with readonly values, closes pandas-dev#28055 (pandas-dev#28074)
  TST: non-strict xfail for period test (pandas-dev#28072)
  DOC: Update whatsnew (pandas-dev#28073)
  CI: disable codecov (pandas-dev#28065)
  CI: Set SHA for codecov upload (pandas-dev#28067)
  BUG: Correct the previous bug fixing on xlim for plotting (pandas-dev#28059)
  CI: Add pip dependence explicitly (pandas-dev#28008)
  DOC: Change document code prun in a row (pandas-dev#28029)
  ...
@ianzur ianzur deleted the issue-#27642-timedelta-merge-asof branch June 27, 2021 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

merge_asof(): cannot use tolerance flag when the index is a TimedeltaIndex
6 participants