diff --git a/src/pandas_profiling/profile_report.py b/src/pandas_profiling/profile_report.py index 2dacb67b7..f0a120b02 100644 --- a/src/pandas_profiling/profile_report.py +++ b/src/pandas_profiling/profile_report.py @@ -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." diff --git a/tests/unit/test_pandas/test_dataframe_empty.py b/tests/unit/test_pandas/test_dataframe_empty.py index 6cf0d115e..46cae9983 100644 --- a/tests/unit/test_pandas/test_dataframe_empty.py +++ b/tests/unit/test_pandas/test_dataframe_empty.py @@ -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)