-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: better concat error messages #9157 #9172
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
count_gen, objs = itertools.tee(objs) | ||
obj_count = len(list(count_gen)) | ||
|
||
if obj_count == 0: |
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.
doesn't len(objects)
accomplish this?
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.
Well, it does look a little hackish. I had issues with objs
being a generator. len(list(objs))
would consume the generator, that's why I used the hack with itertools.tee
.
needs a test |
Yes, still thinking how to design a good test. I still raise a ValueError, but this time with a slightly different error message. Should I test for the wording of the error message? I am not too happy with this solution since it breaks if someone decides to come up with a better message. |
@cel4 you can do a |
@jreback, sorry I am very busy at the moment. I am planning to continue the work here in a week or two. |
I added a draft version how a test could look like. Would appreciate any comments. |
|
@cel4 In the pandas |
Hmh, tests are green. Yet I am not sure if I like this solution. Wouldn't it be better if we also check in |
this needs to address my comments above |
I propose "ValueError: No objects to concatenate" |
@sergeny, I like that suggestion. Unfortunately, I do not have much time at the moment and I totally forgot about that PR. I hope I can finish it soon. |
closing as stale, but if you would like to reopen and fixup pls do. |
Should be ready for a first round of reviews. |
@@ -2552,6 +2552,22 @@ def _constructor(self): | |||
|
|||
tm.assertIsInstance(result, NotADataFrame) | |||
|
|||
def test_empty_sequence_concat(self): | |||
empty_pat = "[Nn]o objects" |
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.
add the issue number here as a comment
looks reasonable. pls add a release note. and squash. (you can put in API changes) |
@jreback, When travis is happy, this should be ready for review once again. |
merged via 58db03e thanks! |
closes #9157
This is a first attempt to improve the error message when trying to concat an empty list/set of objects:
pd.concat([])
currently raises following error:After the tiny fix it is: