Skip to content

Commit 9c29f82

Browse files
committed
fix implementation
1 parent a287424 commit 9c29f82

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pandas/io/pytables.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5235,6 +5235,7 @@ def _unconvert_string_array(
52355235
if isinstance(data[0], bytes):
52365236
ser = Series(data, copy=False).str.decode(encoding, errors=errors)
52375237
data = ser.to_numpy()
5238+
data.flags.writeable = True
52385239
else:
52395240
data = data.astype(dtype, copy=False).astype(object, copy=False)
52405241

pandas/tests/strings/test_strings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def test_repeat_with_null(any_string_dtype, arg, repeat):
9595

9696
def test_empty_str_methods(any_string_dtype):
9797
empty_str = empty = Series(dtype=any_string_dtype)
98+
empty_inferred_str = Series(dtype="str")
9899
if is_object_or_nan_string_dtype(any_string_dtype):
99100
empty_int = Series(dtype="int64")
100101
empty_bool = Series(dtype=bool)
@@ -154,7 +155,7 @@ def test_empty_str_methods(any_string_dtype):
154155
tm.assert_series_equal(empty_str, empty.str.rstrip())
155156
tm.assert_series_equal(empty_str, empty.str.wrap(42))
156157
tm.assert_series_equal(empty_str, empty.str.get(0))
157-
tm.assert_series_equal(empty_object, empty_bytes.str.decode("ascii"))
158+
tm.assert_series_equal(empty_inferred_str, empty_bytes.str.decode("ascii"))
158159
tm.assert_series_equal(empty_bytes, empty.str.encode("ascii"))
159160
# ismethods should always return boolean (GH 29624)
160161
tm.assert_series_equal(empty_bool, empty.str.isalnum())
@@ -596,7 +597,7 @@ def test_decode_errors_kwarg():
596597
ser.str.decode("cp1252")
597598

598599
result = ser.str.decode("cp1252", "ignore")
599-
expected = ser.map(lambda x: x.decode("cp1252", "ignore")).astype(object)
600+
expected = ser.map(lambda x: x.decode("cp1252", "ignore")).astype("str")
600601
tm.assert_series_equal(result, expected)
601602

602603

@@ -751,5 +752,5 @@ def test_get_with_dict_label():
751752
def test_series_str_decode():
752753
# GH 22613
753754
result = Series([b"x", b"y"]).str.decode(encoding="UTF-8", errors="strict")
754-
expected = Series(["x", "y"], dtype="object")
755+
expected = Series(["x", "y"], dtype="str")
755756
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)