Skip to content

Commit 5a9c306

Browse files
committed
remove mixed-string
1 parent dd02d69 commit 5a9c306

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

doc/source/whatsnew/v1.0.0.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ The following methods now also correctly output values for unobserved categories
237237
:meth:`pandas.array` inference changes
238238
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
239239

240-
:meth:`pandas.array` now infers pandas' new extension types in several cases:
240+
:meth:`pandas.array` now infers pandas' new extension types in several cases (:issue:`29791`):
241241

242242
1. Sting data (including missing values) now returns a :class:`arrays.StringArray`.
243243
2. Integer data (including missing values) now returns a :class:`arrays.IntegerArray`.
@@ -350,7 +350,7 @@ Other API changes
350350
- :meth:`Series.dropna` has dropped its ``**kwargs`` argument in favor of a single ``how`` parameter.
351351
Supplying anything else than ``how`` to ``**kwargs`` raised a ``TypeError`` previously (:issue:`29388`)
352352
- When testing pandas, the new minimum required version of pytest is 5.0.1 (:issue:`29664`)
353-
-
353+
- :meth:`pandas.api.types.infer_dtype` returns ``"string"`` rather than ``"mixed"`` for a mixture of strings and NA values (:issue:`29799`)
354354

355355

356356
.. _whatsnew_1000.api.documentation:

pandas/_libs/lib.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,6 @@ def infer_dtype(value: object, skipna: object=None) -> str:
11131113
Results can include:
11141114

11151115
- string
1116-
- mixed-string
11171116
- unicode
11181117
- bytes
11191118
- floating
@@ -1320,11 +1319,9 @@ def infer_dtype(value: object, skipna: object=None) -> str:
13201319
return 'boolean'
13211320

13221321
elif isinstance(val, str):
1322+
# we deliberately ignore skipna
13231323
if is_string_array(values, skipna=True):
1324-
if isnaobj(values).any():
1325-
return "mixed-string"
1326-
else:
1327-
return "string"
1324+
return "string"
13281325

13291326
elif isinstance(val, bytes):
13301327
if is_bytes_array(values, skipna=skipna):

pandas/core/construction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def array(
302302
# timedelta, timedelta64
303303
return TimedeltaArray._from_sequence(data, copy=copy)
304304

305-
elif inferred_dtype in {"string", "mixed-string"}:
305+
elif inferred_dtype == "string":
306306
return StringArray._from_sequence(data, copy=copy)
307307

308308
elif inferred_dtype in {"integer", "mixed-integer"}:

pandas/tests/dtypes/test_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ def test_string(self):
732732
def test_unicode(self):
733733
arr = ["a", np.nan, "c"]
734734
result = lib.infer_dtype(arr, skipna=False)
735-
assert result == "mixed-string"
735+
assert result == "string"
736736

737737
arr = ["a", np.nan, "c"]
738738
result = lib.infer_dtype(arr, skipna=True)

pandas/tests/frame/test_block_internals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,12 @@ def test_constructor_no_pandas_array(self):
615615
def test_add_column_with_pandas_array(self):
616616
# GH 26390
617617
df = pd.DataFrame({"a": [1, 2, 3, 4], "b": ["a", "b", "c", "d"]})
618-
df["c"] = pd.array([1, 2, None, 3])
618+
df["c"] = pd.arrays.PandasArray(np.array([1, 2, None, 3], dtype=object))
619619
df2 = pd.DataFrame(
620620
{
621621
"a": [1, 2, 3, 4],
622622
"b": ["a", "b", "c", "d"],
623-
"c": pd.array([1, 2, None, 3]),
623+
"c": pd.arrays.PandasArray(np.array([1, 2, None, 3], dtype=object)),
624624
}
625625
)
626626
assert type(df["c"]._data.blocks[0]) == ObjectBlock

pandas/tests/internals/test_internals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ def test_block_shape():
12681268

12691269
def test_make_block_no_pandas_array():
12701270
# https://github.com/pandas-dev/pandas/pull/24866
1271-
arr = pd.array([1, 2])
1271+
arr = pd.arrays.PandasArray(np.array([1, 2]))
12721272

12731273
# PandasArray, no dtype
12741274
result = make_block(arr, slice(len(arr)))

0 commit comments

Comments
 (0)