Skip to content

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

Merged
merged 1 commit into from
Oct 18, 2017
Merged

CLN: amended TypeError from pd.concat() to be more informative (GH15796) #17885

merged 1 commit into from
Oct 18, 2017

Conversation

AdamShamlian
Copy link
Contributor

@AdamShamlian AdamShamlian commented Oct 16, 2017

CLN/TST: Added regex matching for exception message

@AdamShamlian
Copy link
Contributor Author

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
Copy link

codecov bot commented Oct 16, 2017

Codecov Report

Merging #17885 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89.05% <100%> (+0.02%) ⬆️
#single 40.31% <0%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/reshape/concat.py 97.6% <100%> (+0.02%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.75% <0%> (-0.1%) ⬇️
pandas/plotting/_converter.py 65.2% <0%> (+1.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c987694...d8436f4. Read the comment docs.

@codecov
Copy link

codecov bot commented Oct 16, 2017

Codecov Report

Merging #17885 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89.03% <100%> (ø) ⬆️
#single 40.31% <0%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/reshape/concat.py 97.58% <100%> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.75% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0a0f5a...4e89d8f. Read the comment docs.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a 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

# 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))
Copy link
Member

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)

# 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"
Copy link
Member

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.

Copy link
Contributor Author

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).

raise TypeError("cannot concatenate a non-NDFrame object")

# multiline string concat is safer with whitespace for regex
# at test_concat.py:181
Copy link
Member

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

@jorisvandenbossche jorisvandenbossche added the Error Reporting Incorrect or improved errors from pandas label Oct 16, 2017
# 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"
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

@AdamShamlian AdamShamlian Oct 17, 2017

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}";'
Copy link
Contributor

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)

Copy link
Contributor Author

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?

Copy link
Contributor

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)

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

@jreback jreback added this to the 0.21.0 milestone Oct 17, 2017
@jreback jreback merged commit 6691285 into pandas-dev:master Oct 18, 2017
@jreback
Copy link
Contributor

jreback commented Oct 18, 2017

thanks @AdamShamlian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERR: better error message for trying to concat non-pandas objects
3 participants