File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 18
18
is_integer ,
19
19
is_scalar ,
20
20
is_timedelta64_dtype ,
21
+ is_bool_dtype
21
22
)
22
23
from pandas .core .dtypes .missing import isna
23
24
@@ -423,8 +424,8 @@ def _bins_to_cuts(
423
424
424
425
def _coerce_to_type (x ):
425
426
"""
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
428
429
handle it
429
430
"""
430
431
dtype = None
@@ -437,6 +438,9 @@ def _coerce_to_type(x):
437
438
elif is_timedelta64_dtype (x ):
438
439
x = to_timedelta (x )
439
440
dtype = np .dtype ("timedelta64[ns]" )
441
+ elif is_bool_dtype (x ):
442
+ x = x .astype (int )
443
+ dtype = x .dtype
440
444
441
445
if dtype is not None :
442
446
# GH 19768: force NaT to NaN during integer conversion
You can’t perform that action at this time.
0 commit comments