sult, expected) @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"] ) # When read_only is None, use read_excel instead of a workbook @pytest.mark.parametrize("read_only", [True, False, None]) def test_read_with_bad_dimension( datapath, ext, header, expected_data, filename, read_only ): # GH 38956, 39001 - no/incorrect dimension information path = datapath("io", "data", "excel", f"{filename}{ext}") if read_only is None: result = pd.read_excel(path, header=header) else: with contextlib.closing( openpyxl.load_workbook(path, read_only=read_only) ) as wb: result = pd.read_excel(wb, engine="openpyxl", header=header) expected = DataFrame(expected_data) tm.assert_frame_equal(result, expected) def test_append_mode_file(ext): # GH 39576 df = DataFrame() with tm.ensure_clean(ext) as f: df.to_excel(f, engine="openpyxl") with ExcelWriter( f, mode="a", engine="openpyxl", if_sheet_exists="new" ) as writer: df.to_excel(writer) # make sure that zip files are not concatenated by making sure that # "docProps/app.xml" only occurs twice in the file data = Path(f).read_bytes() first = data.find(b"docProps/app.xml") second = data.find(b"docProps/app.xml", first + 1) third = data.find(b"docProps/app.xml", second + 1) assert second != -1 and third == -1 # When read_only is None, use read_excel instead of a workbook @pytest.mark.parametrize("read_only", [True, False, None]) def test_read_wi