8000 REG: read_excel with engine specified raises on non-path/non-buffer by rhshadrach · Pull Request #39586 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

REG: read_excel with engine specified raises on non-path/non-buffer #39586

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 11 commits into from
Feb 7, 2021
Merged
Prev Previous commit
Next Next commit
Merge branch 'master' of https://github.com/pandas-dev/pandas into op…
…enpyxl_workbook

� Conflicts:
�	doc/source/whatsnew/v1.2.2.rst
�	pandas/tests/io/excel/test_openpyxl.py
  • Loading branch information
rhshadrach committed Feb 5, 2021
commit 1f16602000f5cce3cbcb87bfd2f000b65d036288
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v1.2.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Fixed regressions
- Fixed regression in :meth:`~DataFrame.to_pickle` failing to create bz2/xz compressed pickle files with ``protocol=5`` (:issue:`39002`)
- Fixed regression in :func:`pandas.testing.assert_series_equal` and :func:`pandas.testing.assert_frame_equal` always raising ``AssertionError`` when comparing extension dtypes (:issue:`39410`)
- Fixed regression in :meth:`~DataFrame.to_csv` opening ``codecs.StreamWriter`` in binary mode instead of in text mode and ignoring user-provided ``mode`` (:issue:`39247`)
- Fixed regression in :meth:`core.window.rolling.Rolling.count` where the ``min_periods`` argument would be set to ``0`` after the operation (:issue:`39554`)
- Fixed regression in :func:`read_excel` that incorrectly raised when the argument ``io`` was a non-path and non-buffer and the ``engine`` argument was specified (:issue:`39528`)
-

.. ---------------------------------------------------------------------------

Expand Down
29 changes: 29 additions & 0 deletions pandas/tests/io/excel/test_openpyxl.py
63FD
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,35 @@ def test_to_excel_with_openpyxl_engine(ext):
styled.to_excel(filename, engine="openpyxl")


@pytest.mark.parametrize(
"header, expected_data",
[
(
0,
{
"Title": [np.nan, "A", 1, 2, 3],
"Unnamed: 1": [np.nan, "B", 4, 5, 6],
"Unnamed: 2": [np.nan, "C", 7, 8, 9],
},
),
(2, {"A": [1, 2, 3], "B": [4, 5, 6], "C": [7, 8, 9]}),
],
)
@pytest.mark.parametrize(
"filename", ["dimension_missing", "dimension_small", "dimension_large"]
)
@pytest.mark.xfail(
LooseVersion(get_version(openpyxl)) < "3.0.0",
reason="openpyxl read-only sheet is incorrect when dimension data is wrong",
)
def test_read_with_bad_dimension(datapath, ext, header, expected_data, filename):
# GH 38956, 39001 - no/incorrect dimension information
path = datapath("io", "data", "excel", f"{filename}{ext}")
result = pd.read_excel(path, header=header)
expected = DataFrame(expected_data)
tm.assert_frame_equal(result, expected)


def test_read_workbook(datapath, ext):
# GH 39528
filename = datapath("io", "data", "excel", "test1" + ext)
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0