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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
9 changes: 9 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,11 @@ 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():
with option_context("future.infer_string", True):
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)
Loading