Repository navigation
merge_asof and prefix_reduction - #4877
Conversation
…None bug in boundary_slice
|
@jcrist, would you be able to take a look at this? |
|
Hi @codercody , this looks like exciting work. I have a few rough suggestions, though I suspect that folks like @TomAugspurger or @jrbourbeau (who know a bit more about dask dataframe) may have more.
|
TomAugspurger
left a comment
There was a problem hiding this comment.
Thanks @codercody, still going through this.
| B = pd.DataFrame({'a': [1, 2, 3, 6, 7], 'right_val': [1, 2, 3, 6, 7]}) | ||
| b = dd.from_pandas(B, npartitions=2) | ||
|
|
||
| C = pd.merge_asof(A, B, on='a', allow_exact_matches=False).set_index('a') |
There was a problem hiding this comment.
Why is the set-index needed here? I haven't looked at the implementation yet, forgive me if that's explained there.
There was a problem hiding this comment.
Sorry. When Pandas does a merge_asof on a particular column, the resulting dataframe gets reindexed 0, 1, .... This is the one place where my implementation differs from Pandas': if your merge_asof on a particular column using mine, it sets the index as that on column. I could alternatively do a reset_index() in my implementation but I find it kind of silly.
There was a problem hiding this comment.
Furthermore, this is causing Travis CI to mess up, since I guess this causes some index to be permuted in a different way.
E AssertionError: Index are different
E
E Index values are different (100.0 %)
E [left]: Index([u'price', u'quantity', u'ticker', u'ask', u'bid'], dtype='object')
E [right]: Index([u'ask', u'bid', u'price', u'quantity', u'ticker'], dtype='object')
Do you know what I should do to fix this to pass Travis CI?
There was a problem hiding this comment.
Ideally we would match pandas output.
We may not be able to entirely in this case. This might be a case where we need each partition to have its own RangeIndex(0, len(partition)).
| if left is None or right is None: | ||
| raise ValueError("Cannot merge_asof on empty DataFrames") | ||
|
|
||
| if isinstance(left, pd.DataFrame) and isinstance(right, pd.DataFrame): |
There was a problem hiding this comment.
@mrocklin what's best for cuDF here? Would a dispatchable merge_asof, and replace these checks with is_dataframe_like be best?
There was a problem hiding this comment.
I think that we should use is_dataframe_like universally.
I think that we should continue to use pd.merge_asof until some other pandas implementation supports the operation, at that point I think that we would either try to add a method, or a dispatchable function. I wouldn't worry about this until that happens though.
There was a problem hiding this comment.
So, to be clear @codercody , if you can replace checks like
isinstance(df, pd.DataFrame)with
is_dataframe_like(df)That would be welcome.
There was a problem hiding this comment.
I was trying to copy line 346 in the merge implementation, where they separately handled when left and right are actually pd.DataFrames and not dd.DataFrames. If you don't want me to handle this case, then I'm just going to delete this check altogether. Is that fine?
…ically created helper functions to module helper functions in compute_heads and compute_tails
TomAugspurger
left a comment
There was a problem hiding this comment.
Can you check on the CI failure: https://travis-ci.org/dask/dask/jobs/544385948#L1798
It's possible you're relying on dict ordering here, while we support Python 3.5.
|
@codercody I see that you reacted with the Confused emoji to @TomAugspurger 's recent comment below:
To expand on this, it looks like the tests are failing, but only in Python 3.5, and not in any newer Python versions. You can see the failure here: https://travis-ci.org/dask/dask/jobs/544385948 DetailsGiven the fact that this is an ordering thing, and that it's only on Python 3.5, Tom was guessing that this was due to expecting that dicts are consistently ordered, which is something that changed between 3.5 and 3.6. In Python 3.6 calling To make things concrete, if you create an environment with Python 3.5 do your tests pass for you? Also, as a quick note, many of the maintainers track PRs by e-mail. We get notifications when someone pushes a new commit or makes a comment, but not when someone reacts to a comment with an emoji, hence the delay in response here. |
|
@TomAugspurger other than the dict ordering issue is this ready to go in, or does it still need more work? This is one of the few substantial outstanding PRs that we have before we might use black. I have a slight preference to black-ify things before the release, which I would ideally like to do soon. (though that's somewhat arbitrary, black could slip, or we could redo this PR after black. |
| B = pd.DataFrame({'a': [1, 2, 3, 6, 7], 'right_val': [1, 2, 3, 6, 7]}) | ||
| b = dd.from_pandas(B, npartitions=2) | ||
|
|
||
| C = pd.merge_asof(A, B, on='a').set_index('a') |
There was a problem hiding this comment.
This still concerns me. I'm looking into why it's necessary now.
|
@codercody apologies for the flurry of commits. Can yo take a look at 0e60df1 and confirm that it looks OK? That matches the output, other than the index. With Dask's merge_asof, each partition has its on Docs probably aren't a blocker. |
|
Sorry, I seem to have broken things (right now I think it's an issue with |
|
fd6cef3 should pass. This is probably good to go, though I would like to see the docs issue from #4877 (comment) addressed eventually. |
|
Still seem to have a column order issue with pandas 0.21.x. |
|
Green check mark :) |
|
Alrighty, here goes. Thanks @codercody, nice work! |
flake8 daskFor merge_asof(left, right), the algorithm is to:
The things I know I messed up in this PR (and would like help fixing) are