Skip to content

Commit 51cb276

Browse files
jbrockmendeljreback
authored andcommitted
CLN: remove checks for inferred_dtype==unicode (pandas-dev#31020)
1 parent 6837794 commit 51cb276

File tree

7 files changed

+8
-9
lines changed

7 files changed

+8
-9
lines changed

pandas/_testing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ def _check_types(l, r, obj="Index"):
613613
assert_attr_equal("dtype", l, r, obj=obj)
614614

615615
# allow string-like to have different inferred_types
616-
if l.inferred_type in ("string", "unicode"):
617-
assert r.inferred_type in ("string", "unicode")
616+
if l.inferred_type in ("string"):
617+
assert r.inferred_type in ("string")
618618
else:
619619
assert_attr_equal("inferred_type", l, r, obj=obj)
620620

pandas/core/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def _ensure_arraylike(values):
201201
"""
202202
if not is_array_like(values):
203203
inferred = lib.infer_dtype(values, skipna=False)
204-
if inferred in ["mixed", "string", "unicode"]:
204+
if inferred in ["mixed", "string"]:
205205
if isinstance(values, tuple):
206206
values = list(values)
207207
values = construct_1d_object_array_from_listlike(values)

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ def infer_dtype_from_array(arr, pandas_dtype: bool = False):
670670

671671
# don't force numpy coerce with nan's
672672
inferred = lib.infer_dtype(arr, skipna=False)
673-
if inferred in ["string", "bytes", "unicode", "mixed", "mixed-integer"]:
673+
if inferred in ["string", "bytes", "mixed", "mixed-integer"]:
674674
return (np.object_, arr)
675675

676676
arr = np.asarray(arr)

pandas/core/indexes/base.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ def _format_data(self, name=None):
910910

911911
# do we want to justify (only do so for non-objects)
912912
is_justify = not (
913-
self.inferred_type in ("string", "unicode")
913+
self.inferred_type in ("string")
914914
or (
915915
self.inferred_type == "categorical" and is_object_dtype(self.categories)
916916
)
@@ -2860,7 +2860,6 @@ def _convert_scalar_indexer(self, key, kind=None):
28602860
"mixed-integer-float",
28612861
"integer-na",
28622862
"string",
2863-
"unicode",
28642863
"mixed",
28652864
]:
28662865
self._invalid_indexer("label", key)

pandas/io/parquet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def validate_dataframe(df: DataFrame):
5151
raise ValueError("to_parquet only supports IO with DataFrames")
5252

5353
# must have value column names (strings only)
54-
if df.columns.inferred_type not in {"string", "unicode", "empty"}:
54+
if df.columns.inferred_type not in {"string", "empty"}:
5555
raise ValueError("parquet must have string column names")
5656

5757
# index level names must be strings

pandas/io/parsers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ def _validate_usecols_arg(usecols):
13041304

13051305
usecols_dtype = lib.infer_dtype(usecols, skipna=False)
13061306

1307-
if usecols_dtype not in ("empty", "integer", "string", "unicode"):
1307+
if usecols_dtype not in ("empty", "integer", "string"):
13081308
raise ValueError(msg)
13091309

13101310
usecols = set(usecols)

pandas/io/stata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ def _encode_strings(self):
23342334
dtype = column.dtype
23352335
if dtype.type == np.object_:
23362336
inferred_dtype = infer_dtype(column, skipna=True)
2337-
if not ((inferred_dtype in ("string", "unicode")) or len(column) == 0):
2337+
if not ((inferred_dtype in ("string")) or len(column) == 0):
23382338
col = column.name
23392339
raise ValueError(
23402340
f"""\

0 commit comments

Comments
 (0)