-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: amended TypeError from pd.concat() to be more informative (GH15796) #17885
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
Hey Pandas team. Long time user here looking to start giving back. I've been burned by this error message plenty in my early days, so a fitting first issue. |
Codecov Report
@@ Coverage Diff @@
## master #17885 +/- ##
==========================================
+ Coverage 91.23% 91.24% +<.01%
==========================================
Files 163 163
Lines 50102 50105 +3
==========================================
+ Hits 45712 45718 +6
+ Misses 4390 4387 -3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17885 +/- ##
==========================================
- Coverage 91.23% 91.22% -0.02%
==========================================
Files 163 163
Lines 50105 50106 +1
==========================================
- Hits 45715 45707 -8
- Misses 4390 4399 +9
Continue to review full report at Codecov.
|
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.
Thanks for starting to contribute!
I added a few comments
pandas/core/reshape/concat.py
Outdated
# at test_concat.py:181 | ||
msg = """cannot concatenate object of type "{0}";""" | ||
msg += " only pd.Series, pd.DataFrame, and pd.Panel" | ||
msg += " objs are valid".format(type(obj)) |
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 write this as
msg = (" ..."
" ... ")
(which is the typical way we write multi-line strings in the codebase)
pandas/tests/reshape/test_concat.py
Outdated
# with the message as a whole, anyways | ||
msg = """cannot concatenate object of type \"(.+?)\";""" | ||
msg += " only pd.Series, pd.DataFrame, and pd.Panel" | ||
msg += " objs are valid" |
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.
same comment here as above.
But also, I think it is fine to only match a part of the error message if that makes it easier.
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.
Thanks, I'll clean this up (which will eliminate the confusing comment as well).
pandas/core/reshape/concat.py
Outdated
raise TypeError("cannot concatenate a non-NDFrame object") | ||
|
||
# multiline string concat is safer with whitespace for regex | ||
# at test_concat.py:181 |
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 am not fully understanding this comment
pandas/core/reshape/concat.py
Outdated
# multiline string concat is safer with whitespace for regex | ||
# at test_concat.py:181 | ||
msg = """cannot concatenate object of type "{0}";""" | ||
msg += " only pd.Series, pd.DataFrame, and pd.Panel" |
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.
no need to mention pd.Panel
as they are deprecated
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.
Ahh, were there plans to maintain it in some "LTS" pre 1.0 release, or is it full-on deprecated?
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.
are you offering to do this ???
haven’t really decided what to do with this yet
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.
No, that sounds decidedly outside the scope of the time I have right now. While I was aware of the deprecation, I thought there was discussion about it being passively maintained. I don't have any horses in the pd.Panel race. Just curious.
edit: I assume you were referring to the Panel deprecation and not this issue.
@@ -262,7 +262,10 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None, | |||
ndims = set() | |||
for obj in objs: | |||
if not isinstance(obj, NDFrame): | |||
raise TypeError("cannot concatenate a non-NDFrame object") | |||
msg = ('cannot concatenate object of type "{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.
actually lets add back Panel, they are current still valid (same below)
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.
Haha, ok. Should I mark it as "... pd.Panel (deprecated)" or leave out the deprecated note?
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 like that first one! (mark as deprecated)
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.
Should be good to go now
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.
Let that last message be living testament to my hubris. Forgot to escape the parens for regex and busted the build system. NOW it should be good to go.
thanks @AdamShamlian |
CLN/TST: Added regex matching for exception message
git diff upstream/master -u -- "*.py" | flake8 --diff