Skip to content

read_excel and Excel File Engine conflict #26736

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 5 commits into from
Jun 10, 2019
Merged

read_excel and Excel File Engine conflict #26736

merged 5 commits into from
Jun 10, 2019

Conversation

alimcmaster1
Copy link
Member

@alimcmaster1 alimcmaster1 commented Jun 8, 2019

cc. @WillAyd

Note I only decided to raise an error when the engine specified to read_excel was different to that of the ExcelFile - otherwise around 15 test cases would need to be changed - let me know what you think

@codecov
Copy link

codecov bot commented Jun 8, 2019

Codecov Report

Merging #26736 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26736      +/-   ##
==========================================
- Coverage   91.78%   91.77%   -0.01%     
==========================================
  Files         174      174              
  Lines       50703    50706       +3     
==========================================
- Hits        46538    46537       -1     
- Misses       4165     4169       +4
Flag Coverage Δ
#multiple 90.37% <100%> (ø) ⬆️
#single 41.8% <0%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/io/excel/_base.py 91.92% <100%> (+0.11%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️

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 cf25c5c...6a1f266. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 8, 2019

Codecov Report

Merging #26736 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26736      +/-   ##
==========================================
- Coverage   91.71%   91.71%   -0.01%     
==========================================
  Files         178      178              
  Lines       50771    50774       +3     
==========================================
  Hits        46567    46567              
- Misses       4204     4207       +3
Flag Coverage Δ
#multiple 90.31% <100%> (ø) ⬆️
#single 41.21% <0%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/excel/_base.py 91.92% <100%> (+0.11%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.94% <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 d47fc0c...f52a53a. Read the comment docs.

@simonjayhawkins simonjayhawkins added Error Reporting Incorrect or improved errors from pandas IO Excel read_excel, to_excel labels Jun 8, 2019
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Can you add a whatsnew?

@@ -289,6 +289,9 @@ def read_excel(io,

if not isinstance(io, ExcelFile):
io = ExcelFile(io, engine=engine)
elif engine and engine != io.engine:
Copy link
Member

Choose a reason for hiding this comment

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

Is io.engine ever None? Coverage here might be a little suspect for cases like:

read_excel(ExcelFile(), engine='xlrd')

which I suppose should work fine (assuming xlrd is default) but may not be covered here explicitly

Copy link
Member Author

Choose a reason for hiding this comment

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

Current behaviour is io.engine in this line will default to 'xlrd' since that's in the ExcelFile constuctor -> added a test case to make this more explicit.

@WillAyd WillAyd added this to the 0.25.0 milestone Jun 8, 2019
@WillAyd
Copy link
Member

WillAyd commented Jun 8, 2019

FYI not necessarily going to cause merge conflicts I think but I also just opened #26740. Depending on which merges first we may need to move the test added here around

@@ -843,6 +843,13 @@ def test_read_excel_squeeze(self, ext):
expected = pd.Series([1, 2, 3], name='a')
tm.assert_series_equal(actual, expected)

def test_read_excel_engine_value(self, ext):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you parameterize with (for the ExcelFile), engine=['xlrd', 'openpyxl']

should fail for both

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to confirm my current implementation doesn't throw for the following case:

e = ExcelFile("blah.any", engine='openpyxl')
pd.read_excel(e, engine='openpyxl')

As around 15 of the test cases in test_excel used this construction - if you think the above should throw them I am happy to update the test cases - ( its just a simple update to the cd_and_set_engine fixture )

@WillAyd
Copy link
Member

WillAyd commented Jun 9, 2019

Can you merge master? Just changed around the structure of the tests I think you should move the new test to the one specific to TestExcelFileRead

@alimcmaster1
Copy link
Member Author

Thanks @WillAyd -the new structure is great btw really splits up the excel tests nicely!

@jreback jreback merged commit f197f50 into pandas-dev:master Jun 10, 2019
@jreback
Copy link
Contributor

jreback commented Jun 10, 2019

thanks @alimcmaster1

@alimcmaster1 alimcmaster1 deleted the mcmali-excel branch December 25, 2019 20:35
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 and ExcelFile engine conflict
4 participants