From ae73723612c8fd27c78cc7e3fb2820ee8179b14a Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Mon, 11 Jan 2021 19:30:55 +0700 Subject: [PATCH] TST: add test for describe include/exclude --- pandas/tests/frame/methods/test_describe.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/tests/frame/methods/test_describe.py b/pandas/tests/frame/methods/test_describe.py index b7692eee16bf8..148263bad0eb0 100644 --- a/pandas/tests/frame/methods/test_describe.py +++ b/pandas/tests/frame/methods/test_describe.py @@ -1,4 +1,5 @@ import numpy as np +import pytest import pandas as pd from pandas import Categorical, DataFrame, Series, Timestamp, date_range @@ -360,3 +361,13 @@ def test_describe_percentiles_integer_idx(self): ], ) tm.assert_frame_equal(result, expected) + + @pytest.mark.parametrize("exclude", ["x", "y", ["x", "y"], ["x", "z"]]) + def test_describe_when_include_all_exclude_not_allowed(self, exclude): + """ + When include is 'all', then setting exclude != None is not allowed. + """ + df = DataFrame({"x": [1], "y": [2], "z": [3]}) + msg = "exclude must be None when include is 'all'" + with pytest.raises(ValueError, match=msg): + df.describe(include="all", exclude=exclude)