From 6cd5f0207e3bba0e491c5c5780310d3a33c10de4 Mon Sep 17 00:00:00 2001 From: Richard Shadrach Date: Sun, 16 Feb 2025 07:59:55 -0500 Subject: [PATCH] cleanup --- pandas/core/strings/accessor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 955638984aab9..87ef62e1aeab4 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -2150,6 +2150,8 @@ def decode(self, encoding, errors: str = "strict", dtype: str | DtypeObj = None) and not is_object_dtype(dtype) ): raise ValueError(f"dtype must be string or object, got {dtype=}") + if dtype is None and get_option("future.infer_string"): + dtype = "str" # TODO: Add a similar _bytes interface. if encoding in _cpython_optimized_decoders: # CPython optimized implementation @@ -2159,8 +2161,6 @@ def decode(self, encoding, errors: str = "strict", dtype: str | DtypeObj = None) f = lambda x: decoder(x, errors)[0] arr = self._data.array result = arr._str_map(f) - if dtype is None and get_option("future.infer_string"): - dtype = "str" return self._wrap_result(result, dtype=dtype) @forbid_nonstring_types(["bytes"])