Skip to content

ENH: Raise error for 'sheet' arg in read_excel #18604

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 3 commits into from
Jul 7, 2018

Conversation

lucianoviola
Copy link
Contributor

@lucianoviola lucianoviola commented Dec 2, 2017

I was also thinking about the possibility of raising a warning instead, and do something like:

if sheet in kwds:
    sheet_name = sheet

@pep8speaks
Copy link

pep8speaks commented Dec 2, 2017

Hello @lucianoviola! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on July 07, 2018 at 16:23 Hours UTC

@lucianoviola lucianoviola force-pushed the excel_io branch 2 times, most recently from d257639 to 1e6b21a Compare December 2, 2017 23:37
@codecov
Copy link

codecov bot commented Dec 2, 2017

Codecov Report

Merging #18604 into master will decrease coverage by 0.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18604      +/-   ##
==========================================
- Coverage   91.46%   91.45%   -0.02%     
==========================================
  Files         157      157              
  Lines       51439    51441       +2     
==========================================
- Hits        47051    47043       -8     
- Misses       4388     4398      +10
Flag Coverage Δ
#multiple 89.32% <50%> (-0.01%) ⬇️
#single 40.6% <0%> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/io/excel.py 80.3% <50%> (-0.09%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.81% <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 0e16818...1e6b21a. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 2, 2017

Codecov Report

Merging #18604 into master will decrease coverage by 0.5%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18604      +/-   ##
==========================================
- Coverage   91.95%   91.45%   -0.51%     
==========================================
  Files         160      157       -3     
  Lines       49837    51441    +1604     
==========================================
+ Hits        45830    47043    +1213     
- Misses       4007     4398     +391
Flag Coverage Δ
#multiple 89.32% <50%> (-1.02%) ⬇️
#single 40.6% <0%> (-1.48%) ⬇️
Impacted Files Coverage Δ
pandas/io/excel.py 80.3% <50%> (ø)
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/plotting/_compat.py 62% <0%> (-28.91%) ⬇️
pandas/core/missing.py 84.3% <0%> (-7.35%) ⬇️
pandas/io/parquet.py 65.38% <0%> (-6.42%) ⬇️
pandas/core/accessor.py 93.75% <0%> (-4.97%) ⬇️
pandas/core/ops.py 91.77% <0%> (-4.7%) ⬇️
pandas/plotting/_timeseries.py 60.73% <0%> (-4.58%) ⬇️
pandas/io/formats/terminal.py 16.43% <0%> (-4.55%) ⬇️
... and 116 more

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 e84cf2a...7e38b46. Read the comment docs.

@@ -225,6 +225,9 @@ def read_excel(io, sheet_name=0, header=0, skiprows=None, skip_footer=0,
elif 'sheetname' in kwds:
raise TypeError("Cannot specify both `sheet_name` and `sheetname`. "
"Use just `sheet_name`")
if 'sheet' in kwds:
raise TypeError("read_excel() got an unexpected keyword argument "
"`sheet`")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not generalizable. What happens if I were to pass in an argument called "Sheet" ? Your check wouldn't catch that. You should develop a more general checker that checks for any keywords that don't correspond to ones that we accept.

@gfyoung
Copy link
Member

gfyoung commented Dec 3, 2017

I was also thinking about the possibility of raising a warning instead, and do something like:

Potentially. I personally don't feel too against just raising for incorrect arguments that we don't explicitly document. However, let's see what others have to say? @jreback @jorisvandenbossche ?

@gfyoung gfyoung added Error Reporting Incorrect or improved errors from pandas IO Excel read_excel, to_excel labels Dec 3, 2017
@jreback
Copy link
Contributor

jreback commented Dec 3, 2017

the way to do this is to stop passing thru **kwds, rather explicity name any other args (which I don't think there are any), if there are they should be explicity named and in the doc-strings.

@jorisvandenbossche
Copy link
Member

the way to do this is to stop passing thru **kwds, rather explicity name any other args (which I don't think there are any), if there are they should be explicity named and in the doc-strings.

That is indeed the way to go, but currently kwds are passed to TextParser, so we should investigate if there are possible other keyword arguments that could be used in read_excel that are supported by TextParser.

@lucianoviola
Copy link
Contributor Author

Ok. I'll have a look at TextParser!

@jreback
Copy link
Contributor

jreback commented Jan 21, 2018

can you rebase and respond to comments.

@lucianoviola
Copy link
Contributor Author

I apologize @jreback. I will get back on it.

@jreback jreback added this to the 0.24.0 milestone Jul 7, 2018
@jreback
Copy link
Contributor

jreback commented Jul 7, 2018

this is all fixed up.

@jreback jreback merged commit def7a73 into pandas-dev:master Jul 7, 2018
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
* ENH: Raise error for read_excel possible "sheet" argument in kwargs (pandas-dev#17994)
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 IO Excel read_excel, to_excel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

read_excel does not raise error with wrong keyword arg
5 participants