Skip to content

Commit db60d48

Browse files
authored
fix: issue#1104 empty dataframe (#1238)
* fix: raise value error for empty dataframe * fix: empty DataFrame unit test
1 parent 087723e commit db60d48

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/pandas_profiling/profile_report.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ def __init__(
8585
if df is None and not lazy:
8686
raise ValueError("Can init a not-lazy ProfileReport with no DataFrame")
8787

88+
if df is not None and df.empty:
89+
raise ValueError(
90+
"DataFrame is empty. Please provide a non-empty DataFrame."
91+
)
92+
8893
if config_file is not None and minimal:
8994
raise ValueError(
9095
"Arguments `config_file` and `minimal` are mutually exclusive."

tests/unit/test_pandas/test_dataframe_empty.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,5 @@
1313
],
1414
)
1515
def test_empty(test_data):
16-
profile = ProfileReport(test_data, progress_bar=False)
17-
description = profile.get_description()
18-
19-
assert len(description["correlations"]) == 0
20-
assert len(description["missing"]) == 0
21-
22-
html = profile.to_html()
23-
assert "Dataset is empty" in html
16+
with pytest.raises(ValueError):
17+
ProfileReport(test_data, progress_bar=False)

0 commit comments

Comments
 (0)