Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas/core/methods/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def _select_data(self) -> DataFrame:
include=self.include,
exclude=self.exclude,
)
if len(data.columns) == 0:
msg = "No columns match the specified include or exclude data types"
raise ValueError(msg)
return data


Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/frame/methods/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ def test_describe_when_include_all_exclude_not_allowed(self, exclude):
with pytest.raises(ValueError, match=msg):
df.describe(include="all", exclude=exclude)

def test_describe_when_included_dtypes_not_present(self):
# GH#61863
df = DataFrame({"a": [1, 2, 3]})
msg = "No columns match the specified include or exclude data types"
with pytest.raises(ValueError, match=msg):
df.describe(include=["datetime"])

def test_describe_with_duplicate_columns(self):
df = DataFrame(
[[1, 1, 1], [2, 2, 2], [3, 3, 3]],
Expand Down
Loading