Skip to content

Commit 996c072

Browse files
committed
add an edge case where dtype is bool
1 parent 1dab146 commit 996c072

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/core/arrays/integer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pandas.core.dtypes.cast import astype_nansafe
1313
from pandas.core.dtypes.common import (
1414
is_bool_dtype,
15+
is_bool,
1516
is_float,
1617
is_float_dtype,
1718
is_integer,
@@ -213,7 +214,11 @@ def coerce_to_array(values, dtype, mask=None, copy=False):
213214
values = values.copy()
214215
else:
215216
if isinstance(values, list):
216-
values = np.array(values, dtype=object, copy=copy)
217+
if len(values) > 0:
218+
if not is_bool(values[0]):
219+
values = np.array(values, dtype=object, copy=copy)
220+
else:
221+
values = np.array(values, copy=copy)
217222
else:
218223
values = np.array(values, copy=copy)
219224

0 commit comments

Comments
 (0)