Skip to content

Commit 983967f

Browse files
committed
revert condition change
1 parent 5f74875 commit 983967f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pandas/core/arrays/numeric.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,10 @@ def _coerce_to_data_and_mask(values, dtype, copy: bool, dtype_cls: type[NumericD
169169
values = np.asarray(values)
170170
else:
171171
values = np.array(values, copy=copy)
172+
inferred_type = None
172173
if values.dtype == object or is_string_dtype(values.dtype):
173-
if is_string_dtype(values.dtype):
174-
inferred_type = "string"
175-
if (
176-
dtype is None
177-
and values.dtype == object
178-
and lib.is_bool_array(values, skipna=True)
179-
):
174+
inferred_type = lib.infer_dtype(values, skipna=True)
175+
if inferred_type == "boolean" and dtype is None:
180176
# object dtype array of bools
181177
name = dtype_cls.__name__.strip("_")
182178
raise TypeError(f"{values.dtype} cannot be converted to {name}")

0 commit comments

Comments
 (0)