From d3305519bb4ac131d69cf5ffd0cc270c31ba522e Mon Sep 17 00:00:00 2001 From: LiuSeeker Date: Thu, 15 Aug 2019 10:50:33 -0300 Subject: [PATCH 1/4] Fixes issue #13628 --- pandas/tests/arrays/categorical/test_missing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/arrays/categorical/test_missing.py b/pandas/tests/arrays/categorical/test_missing.py index 1b62479530d24..85cce074d11dc 100644 --- a/pandas/tests/arrays/categorical/test_missing.py +++ b/pandas/tests/arrays/categorical/test_missing.py @@ -5,7 +5,7 @@ from pandas.core.dtypes.dtypes import CategoricalDtype -from pandas import Categorical, Index, isna +from pandas import Categorical, Series, Index, isna import pandas.util.testing as tm @@ -59,11 +59,13 @@ def test_set_item_nan(self): ), (dict(), "Must specify a fill 'value' or 'method'."), (dict(method="bad"), "Invalid fill method. Expecting .* bad"), + (dict(value=Series([1, 2, 3, 4, "a"])), "fill value must be in categories"), ], ) def test_fillna_raises(self, fillna_kwargs, msg): # https://github.com/pandas-dev/pandas/issues/19682 - cat = Categorical([1, 2, 3]) + # https://github.com/pandas-dev/pandas/issues/13628 + cat = Categorical([1, 2, 3, None, None]) with pytest.raises(ValueError, match=msg): cat.fillna(**fillna_kwargs) From 8bb11319d5afcac7fb262ed1a0c1d316027f813c Mon Sep 17 00:00:00 2001 From: LiuSeeker Date: Thu, 15 Aug 2019 12:57:09 -0300 Subject: [PATCH 2/4] Fixes issue #13628 fix --- doc/source/whatsnew/v0.25.1.rst | 2 +- pandas/tests/arrays/categorical/test_missing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.25.1.rst b/doc/source/whatsnew/v0.25.1.rst index 21f1fa7ddec1f..9f78d0e4d0658 100644 --- a/doc/source/whatsnew/v0.25.1.rst +++ b/doc/source/whatsnew/v0.25.1.rst @@ -25,7 +25,7 @@ Bug fixes Categorical ^^^^^^^^^^^ -- +- Added test to assert the :func:`fillna` raises the correct ValueError message when the value isn't a value from categories (:issue:`13628`) - - diff --git a/pandas/tests/arrays/categorical/test_missing.py b/pandas/tests/arrays/categorical/test_missing.py index 85cce074d11dc..7402e5be5f4a5 100644 --- a/pandas/tests/arrays/categorical/test_missing.py +++ b/pandas/tests/arrays/categorical/test_missing.py @@ -5,7 +5,7 @@ from pandas.core.dtypes.dtypes import CategoricalDtype -from pandas import Categorical, Series, Index, isna +from pandas import Categorical, Index, isna, Series import pandas.util.testing as tm From cff5265fd34d6d77f7561ffc3f643daf438bc98a Mon Sep 17 00:00:00 2001 From: LiuSeeker Date: Thu, 15 Aug 2019 15:19:23 -0300 Subject: [PATCH 3/4] isort Fixes #13628 --- pandas/tests/arrays/categorical/test_missing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/arrays/categorical/test_missing.py b/pandas/tests/arrays/categorical/test_missing.py index 7402e5be5f4a5..3037ac79cd592 100644 --- a/pandas/tests/arrays/categorical/test_missing.py +++ b/pandas/tests/arrays/categorical/test_missing.py @@ -5,7 +5,7 @@ from pandas.core.dtypes.dtypes import CategoricalDtype -from pandas import Categorical, Index, isna, Series +from pandas import Categorical, Index, Series, isna import pandas.util.testing as tm From 9b85393affab92abc7f0413dd91809ae4b86d904 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 15 Aug 2019 15:32:34 -0500 Subject: [PATCH 4/4] move to 1.0 --- doc/source/whatsnew/v0.25.1.rst | 1 - doc/source/whatsnew/v1.0.0.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.1.rst b/doc/source/whatsnew/v0.25.1.rst index 9f78d0e4d0658..751829f11570f 100644 --- a/doc/source/whatsnew/v0.25.1.rst +++ b/doc/source/whatsnew/v0.25.1.rst @@ -25,7 +25,6 @@ Bug fixes Categorical ^^^^^^^^^^^ -- Added test to assert the :func:`fillna` raises the correct ValueError message when the value isn't a value from categories (:issue:`13628`) - - diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index aeed3668fe774..c4f1317ad0c67 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -87,6 +87,7 @@ Bug fixes Categorical ^^^^^^^^^^^ +- Added test to assert the :func:`fillna` raises the correct ValueError message when the value isn't a value from categories (:issue:`13628`) - -