-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
Raise more specific exception on concat([None]) #8501
Conversation
@jorisvandenbossche you think this is an API change? seems completely back-compat |
@@ -679,7 +683,7 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, | |||
If a dict is passed, the sorted keys will be used as the `keys` | |||
argument, unless it is passed, in which case the values will be | |||
selected (see below). Any None objects will be dropped silently unless | |||
they are all None in which case an Exception will be raised | |||
they are all None in which case a ConcatenationError will be raised |
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.
Maybe this could just be a ValueError?
I'm not opposed to more specific exceptions, but if you are going to define a new exception, it probably should be exposed a higher level of the API than pandas.tools.merge
. I'm guessing there is precedent for this somewhere?
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.
The pattern I'm following is from MergeError (declared on line 44). MergeError is raised when something is wrong with a caller's inputs to merge().
ValueError would also be an improvement but I figured I should follow the pattern used in the file.
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.
OK, fair enough.
Yeah, as far as I understand it correctly, this should be back compat (as if a user is checking for an Exception now, this will still work for ConcatenationError). However, I do follow @shoyer here in the question if it is not more useful to provide eg ValueError. |
I think So IMHO, I think let's make |
Updated to remove ConcatenationError and make ValueError more central, as suggested. I'll leave the deprecation of MergeError to you folks if that's OK. Not sure how you'd like to document/go forward with that kind of thing. |
Can you sqaush your commits? |
@jorisvandenbossche done! |
@thatneat can you add a release note to v0.15.0 API changes (reference this issue, saying a squash and I think good to go |
merged via ce79c80 thanks! |
More specific exception allows for a safer, more explicit catch by a caller.
ConcatenationError follows the pattern of MergeError which is used in the same file when something is wrong with a caller's inputs to merge().