-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC/ERR: better error message on no common merge keys #19427
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
Conversation
It seems that the failed test has nothing to do with the content of the commit though.. |
Codecov Report
@@ Coverage Diff @@
## master #19427 +/- ##
==========================================
- Coverage 91.6% 89.96% -1.64%
==========================================
Files 150 150
Lines 48750 48726 -24
==========================================
- Hits 44657 43837 -820
- Misses 4093 4889 +796
Continue to review full report at Codecov.
|
Can you add a test for this, and a release note? What's the output look like for large DataFrames? Does the repr truncation work correctly? |
pandas/core/frame.py
Outdated
@@ -233,7 +233,7 @@ | |||
-------- | |||
merge_ordered | |||
merge_asof | |||
|
|||
DataFrame.join : For index-based merge operations |
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.
I think you can remove the explanation, everything other than the name. I'm not sure what numpydoc does with it, but those are turned into hyperlinks for the HTML docs.
Release note added, |
Yes, see Ignore my comment about large dataframes I think. |
pandas/core/reshape/merge.py
Outdated
@@ -1028,7 +1028,14 @@ def _validate_specification(self): | |||
common_cols = self.left.columns.intersection( | |||
self.right.columns) | |||
if len(common_cols) == 0: | |||
raise MergeError('No common columns to perform merge on') | |||
raise MergeError('No common columns to perform merge on. ' | |||
'Merge options: right_on={ron}, ' |
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 change the order to be left_on, right_on, left_index, right_index
, to match the order in the signature?
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.
Oh sure I can. will do it.
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.
to make this more readable you can break it like
raise MergeError(
'No common ......'
)
pandas/core/reshape/merge.py
Outdated
@@ -1028,7 +1028,14 @@ def _validate_specification(self): | |||
common_cols = self.left.columns.intersection( | |||
self.right.columns) | |||
if len(common_cols) == 0: | |||
raise MergeError('No common columns to perform merge on') | |||
raise MergeError('No common columns to perform merge on. ' | |||
'Merge options: right_on={ron}, ' |
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.
to make this more readable you can break it like
raise MergeError(
'No common ......'
)
pandas/core/reshape/merge.py
Outdated
'left_on={lon}, right_index={ridx}, ' | ||
'left_index={lidx}' | ||
.format(ron=self.right_on, | ||
lon=self.left_on, |
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 update the test for this (it prob just raises) and match the error message with assert_raises_regex
can you rebase and update |
The line break and the order of options are modified. |
- Let MergeError emit values keyword arguments. - Add DataFrame.join on 'See also' section of pandas.merge. - Add an item in whatsnew - Update test_no_overlap_more_informative_error to check the message from MergeError
thanks @swyoon |
thanks for kind reviews! @jreback @TomAugspurger |
git diff upstream/master -u -- "*.py" | flake8 --diff
DataFrame.join
onSee also
section ofpandas.merge