diff --git a/python/pyarrow/tests/test_pandas.py b/python/pyarrow/tests/test_pandas.py index 2a782de1648..c3153e82b74 100644 --- a/python/pyarrow/tests/test_pandas.py +++ b/python/pyarrow/tests/test_pandas.py @@ -3095,8 +3095,6 @@ def test_category(self): arrays = { 'cat_strings': pd.Categorical(v1 * repeats), - 'cat_strings_with_na': pd.Categorical(v1 * repeats, - categories=['foo', 'bar']), 'cat_ints': pd.Categorical(v2 * repeats), 'cat_binary': pd.Categorical(v3 * repeats), 'cat_strings_ordered': pd.Categorical( @@ -3121,13 +3119,23 @@ def _check(v): tm.assert_series_equal(pd.Series(result), pd.Series(v)) arrays = [ - pd.Categorical(['a', 'b', 'c'], categories=['a', 'b']), - pd.Categorical(['a', 'b', 'c'], categories=['a', 'b'], + pd.Categorical(['a', 'b', None], categories=['a', 'b']), + pd.Categorical(['a', 'b', None], categories=['a', 'b'], ordered=True) ] for arr in arrays: _check(arr) + def test_category_construction_deprecation(self): + # GH-49255 + if Version(pd.__version__) < Version("3.0.0"): + pytest.skip("out-of-category deprecation added in pandas 3.0") + with pytest.warns( + DeprecationWarning, + match="Constructing a Categorical with a dtype and " + "values containing non-null entries"): + pd.Categorical(['a', 'b', 'c'], categories=['a', 'b']) + def test_empty_category(self): # ARROW-2443 df = pd.DataFrame({'cat': pd.Categorical([])}) diff --git a/python/setup.cfg b/python/setup.cfg index 2d6558009b1..58e401185a8 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -27,6 +27,8 @@ filterwarnings = error:The SparseDataFrame:FutureWarning # https://github.com/apache/arrow/issues/38239 ignore:Setting custom ClientSession:DeprecationWarning + # https://github.com/apache/arrow/issues/49255 + error:Constructing a Categorical with a dtype and values containing non-null entries:DeprecationWarning # Get a debug traceback when a test takes a really long time faulthandler_timeout = 300