Skip to content

Commit 93c52e4

Browse files
authored
BUG: read_excel skips single-column empty rows (#40214)
1 parent f290b65 commit 93c52e4

File tree

8 files changed

+10
-0
lines changed

8 files changed

+10
-0
lines changed

doc/source/whatsnew/v1.3.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ I/O
537537
- :meth:`read_sql` returned an empty generator if ``chunksize`` was no-zero and the query returned no results. Now returns a generator with a single empty dataframe (:issue:`34411`)
538538
- Bug in :func:`read_hdf` returning unexpected records when filtering on categorical string columns using ``where`` parameter (:issue:`39189`)
539539
- Bug in :func:`read_sas` raising ``ValueError`` when ``datetimes`` were null (:issue:`39725`)
540+
- Bug in :func:`read_excel` dropping empty values from single-column spreadsheets (:issue:`39808`)
540541

541542
Period
542543
^^^^^^

pandas/io/excel/_base.py

+1
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ def parse(
598598
skiprows=skiprows,
599599
nrows=nrows,
600600
na_values=na_values,
601+
skip_blank_lines=False, # GH 39808
601602
parse_dates=parse_dates,
602603
date_parser=date_parser,
603604
thousands=thousands,
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

pandas/tests/io/excel/test_readers.py

+8
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,14 @@ def test_no_header_with_list_index_col(self, read_ext):
11851185
)
11861186
tm.assert_frame_equal(expected, result)
11871187

1188+
def test_one_col_noskip_blank_line(self, read_ext):
1189+
# GH 39808
1190+
file_name = "one_col_blank_line" + read_ext
1191+
data = [0.5, np.nan, 1, 2]
1192+
expected = DataFrame(data, columns=["numbers"])
1193+
result = pd.read_excel(file_name)
1194+
tm.assert_frame_equal(result, expected)
1195+
11881196

11891197
class TestExcelFileRead:
11901198
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)