Skip to content

TST: add test for dtype argument in str.decode #61872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 28, 2025
Merged
Changes from 2 commits
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,
option_context,
)
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
with option_context("future.infer_string", True):
ser = Series([b"a", b"b", b"c"]) # Use byte strings
result = ser.str.decode("utf-8", dtype=None)
expected = Series(["a", "b", "c"], dtype="str")
tm.assert_series_equal(result, expected)