Skip to content
Merged
Changes from 1 commit
Commits
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
10 changes: 10 additions & 0 deletions pandas/tests/strings/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Index,
MultiIndex,
Series,
set_option,
)
import pandas._testing as tm
from pandas.core.strings.accessor import StringMethods
Expand Down Expand Up @@ -778,3 +779,12 @@ def test_series_str_decode():
result = Series([b"x", b"y"]).str.decode(encoding="UTF-8", errors="strict")
expected = Series(["x", "y"], dtype="str")
tm.assert_series_equal(result, expected)


def test_decode_with_dtype_none():
# Ensure that future.infer_string is enabled
set_option("future.infer_string", True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the option_context context manager

ser = Series([b"a", b"b", b"c"]) # Use byte strings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ser = Series([b"a", b"b", b"c"]) # Use byte strings
ser = Series([b"a", b"b", b"c"])

result = ser.str.decode("utf-8", dtype=None)
expected = Series(["a", "b", "c"], dtype="str")
tm.assert_series_equal(result, expected)