Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
4 changes: 0 additions & 4 deletions pandas/core/arrays/string_.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@ def __setitem__(self, key, value):

super().__setitem__(key, value)

def fillna(self, value=None, method=None, limit=None):
# TODO: validate dtype
return super().fillna(value, method, limit)

def astype(self, dtype, copy=True):
dtype = pandas_dtype(dtype)
if isinstance(dtype, StringDtype):
Expand Down
18 changes: 18 additions & 0 deletions pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,24 @@ def test_reduce_missing(skipna, dtype):
assert pd.isna(result)


def test_fillna_args():
# GH 37987

arr = pd.array(["a", pd.NA], dtype="string")

res = arr.fillna(value="b")
expected = pd.array(["a", "b"], dtype="string")
tm.assert_extension_array_equal(res, expected)

res = arr.fillna(value=np.str_("b"))
expected = pd.array(["a", "b"], dtype="string")
tm.assert_extension_array_equal(res, expected)

msg = "Cannot set non-string value '1' into a StringArray."
with pytest.raises(ValueError, match=msg):
arr.fillna(value=1)


@td.skip_if_no("pyarrow", min_version="0.15.0")
def test_arrow_array(dtype):
# protocol added in 0.15.0
Expand Down