Skip to content

Commit

Permalink
fix: issue#1104 empty dataframe (#1238)
Browse files Browse the repository at this point in the history
* fix: raise value error for empty dataframe

* fix: empty DataFrame unit test
  • Loading branch information
Sohaib90 authored Jan 24, 2023
1 parent 087723e commit db60d48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/pandas_profiling/profile_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ def __init__(
if df is None and not lazy:
raise ValueError("Can init a not-lazy ProfileReport with no DataFrame")

if df is not None and df.empty:
raise ValueError(
"DataFrame is empty. Please provide a non-empty DataFrame."
)

if config_file is not None and minimal:
raise ValueError(
"Arguments `config_file` and `minimal` are mutually exclusive."
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/test_pandas/test_dataframe_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,5 @@
],
)
def test_empty(test_data):
profile = ProfileReport(test_data, progress_bar=False)
description = profile.get_description()

assert len(description["correlations"]) == 0
assert len(description["missing"]) == 0

html = profile.to_html()
assert "Dataset is empty" in html
with pytest.raises(ValueError):
ProfileReport(test_data, progress_bar=False)

0 comments on commit db60d48

Please sign in to comment.