Skip to content

Commit aabbd95

Browse files
committed
Add bool to int coerce
1 parent 1ffdf50 commit aabbd95

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/core/reshape/tile.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
is_integer,
1919
is_scalar,
2020
is_timedelta64_dtype,
21+
is_bool_dtype
2122
)
2223
from pandas.core.dtypes.missing import isna
2324

@@ -423,8 +424,8 @@ def _bins_to_cuts(
423424

424425
def _coerce_to_type(x):
425426
"""
426-
if the passed data is of datetime/timedelta type,
427-
this method converts it to numeric so that cut method can
427+
if the passed data is of datetime/timedelta or bool type,
428+
this method converts it to numeric so that cut or qcut method can
428429
handle it
429430
"""
430431
dtype = None
@@ -437,6 +438,9 @@ def _coerce_to_type(x):
437438
elif is_timedelta64_dtype(x):
438439
x = to_timedelta(x)
439440
dtype = np.dtype("timedelta64[ns]")
441+
elif is_bool_dtype(x):
442+
x = x.astype(int)
443+
dtype = x.dtype
440444

441445
if dtype is not None:
442446
# GH 19768: force NaT to NaN during integer conversion

0 commit comments

Comments
 (0)