pola-rs/polars · error · NoDataError
empty Excel sheet\n\nIf you want to read this as an empty Da
Error message
empty Excel sheet\n\nIf you want to read this as an empty DataFrame, set `raise_if_empty=False`.
What it means
NoDataError raised by _empty_frame after the Excel reader produced a zero-row, zero-column result. It means the sheet exists but contains no data; the message points at raise_if_empty=False as the way to accept an empty DataFrame instead.
Source
Thrown at py-polars/src/polars/io/spreadsheet/functions.py:1013
):
null_cols.append(col_name)
if null_cols:
df = df.drop(*null_cols)
if df.height == df.width == 0:
return _empty_frame(raise_if_empty)
if drop_empty_rows:
return df.filter(~F.all_horizontal(F.all().is_null()))
return df
def _empty_frame(raise_if_empty: bool) -> pl.DataFrame: # noqa: FBT001
if raise_if_empty:
msg = (
"empty Excel sheet"
"\n\nIf you want to read this as an empty DataFrame, set `raise_if_empty=False`."
)
raise NoDataError(msg)
return pl.DataFrame()
def _reorder_columns(
df: pl.DataFrame, columns: Sequence[int] | Sequence[str] | None
) -> pl.DataFrame:
if columns:
from polars.selectors import by_index, by_name
cols = (
by_index(*columns)
if is_non_empty_sequence_of(columns, int)
else by_name(*columns)
)
df = df.select(cols)
return df
View on GitHub (pinned to 5d8ebabf11)
Solutions
- Set raise_if_empty=False to read the empty sheet as an empty DataFrame, or point to a non-empty sheet.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at py-polars/src/polars/io/spreadsheet/functions.py:1010 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@5d8ebabf11 (2026-08-19).
Data as JSON: /api/errors/5d2ca7bf0533fae4.
Report an issue: GitHub.