diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 4b423175172d2..e816bd4cd4026 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -1111,6 +1111,7 @@ _TYPE_MAP = { "complex128": "complex", "c": "complex", "string": "string", + str: "string", "S": "bytes", "U": "string", "bool": "boolean", diff --git a/pandas/tests/dtypes/test_inference.py b/pandas/tests/dtypes/test_inference.py index b3c6015475674..907991b97ead1 100644 --- a/pandas/tests/dtypes/test_inference.py +++ b/pandas/tests/dtypes/test_inference.py @@ -1267,9 +1267,9 @@ def test_interval(self): @pytest.mark.parametrize("klass", [pd.array, Series]) @pytest.mark.parametrize("skipna", [True, False]) @pytest.mark.parametrize("data", [["a", "b", "c"], ["a", "b", pd.NA]]) - def test_string_dtype(self, data, skipna, klass): + def test_string_dtype(self, data, skipna, klass, nullable_string_dtype): # StringArray - val = klass(data, dtype="string") + val = klass(data, dtype=nullable_string_dtype) inferred = lib.infer_dtype(val, skipna=skipna) assert inferred == "string"