-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: Add merge type validation on pandas.merge
#59435
ENH: Add merge type validation on pandas.merge
#59435
Conversation
pandas/core/reshape/merge.py
Outdated
@@ -350,7 +350,10 @@ def merge( | |||
left_df = _validate_operand(left) | |||
left._check_copy_deprecation(copy) | |||
right_df = _validate_operand(right) | |||
if how == "cross": | |||
merge_type = ["left", "right", "inner", "outer", "cross"] |
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.
This should probably be in _MergeOperation
.
And a test is needed
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.
@mroeschke - moved it to _MergeOperation
and added asof
as valid Merge Type.
Added test function to validate it as well. Thanks
@mroeschke - Added tests and added asof as valid merge type, running
|
Please view the CI logs as another test needs fixing https://github.com/pandas-dev/pandas/actions/runs/10337314281/job/28614031854?pr=59435 |
…w-param-validation
7f8b512
to
86b4055
Compare
pre-commit.ci autofix |
Thanks @KevsterAmp |
* add merge type validation on pandas.merge * add ENH to latest whatsnew doc * move merge type validation to _MergeOperation class * add tests on merge validation; add asof as valid mergetype * change merge_type from tuple to dict * change ValueError message to updated change * change Error message on merge type * update test error messages for merge type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Matthew Roeschke <[email protected]>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new featureTests on pandas.merge
Error Reproducible Example
Not sure if it should raise
ValueError
orMergeError