BUG/DTYPES: preserve bools in convert_objects
State: closed

closes #7126


Labels:
name: Bug
name: Enhancement
name: Dtype Conversions
description: Unexpected or buggy dtype conversions
name: Numeric Operations
description: Arithmetic, Comparison, and Logical operations

Comments:
do a perf test on the suite just in case

yep

needs a doc to note that now `convert_objects` won't upcast `bool`

hm actually it never did up cast ... only issue was when there was mixed bool + others

ahh..yes mixed is always tricky

i think just an oversight, as there IS a `util.is_bool_object` function

yep....i have always modified `maybe_convert_objects` (except for a long time ago)

`maybe_convert_objects` differentiates between `bool` and general numeric types so it ends up returning its input if the input is mixed bool + others, so then the issue was that in `maybe_convert_numeric` no checking for bools was done so it would fail all the `elif` checks and go to `nan`.

rats looks like cparser depends a lot on the current behavior

i wonder if there's a huge ML discussion somewhere about the distinction between bool and int even tho bool inherits from int

@jreback good 2 go?

oh wait perf

looks fine (but check perf)

ran it 4 times, pretty variable on different parts of the codebase:

Round 1:

```
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
frame_ctor_dtindex_BQuarterEndx2             |   1.4610 |   1.2843 |   1.1376 |
frame_assign_timeseries_index                |   0.6957 |   0.6104 |   1.1398 |
strings_contains_few                         |   5.3413 |   4.6817 |   1.1409 |
frame_ctor_dtindex_BDayx1                    |   1.4300 |   1.1743 |   1.2177 |
frame_ctor_dtindex_BYearBeginx1              |   1.5349 |   1.2330 |   1.2449 |
reindex_multiindex                           |   1.5914 |   1.2546 |   1.2684 |
frame_ctor_dtindex_BYearEndx1                |   1.7547 |   1.2757 |   1.3755 |
frame_mult                                   |   6.4913 |   4.0673 |   1.5959 |
frame_add_st                                 |   6.1157 |   3.8283 |   1.5975 |
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
```

Round 2 just on a regex that matches most of the previous round's benches:

```
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
frame_ctor_dtindex_BMonthBeginx1             |   1.4087 |   1.2794 |   1.1011 |
frame_ctor_dtindex_CBMonthEndx1              |   3.1866 |   2.7313 |   1.1667 |
eval_frame_mult_python                       |  19.4876 |  14.1617 |   1.3761 |
frame_mult_st                                |   5.5260 |   3.9387 |   1.4030 |
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
```

Round 3 (same as the previous round):

```
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
frame_ctor_dtindex_CustomBusinessDayx2       |   1.2734 |   1.2634 |   1.0079 |
frame_mult_st                                |   3.9593 |   3.9230 |   1.0093 |
frame_ctor_dtindex_Secondx2                  |   0.9654 |   0.9537 |   1.0123 |
eval_frame_mult_python_one_thread            |  14.0200 |  13.7023 |   1.0232 |
frame_ctor_dtindex_BYearBeginx2              |   1.3304 |   1.2457 |   1.0680 |
strings_contains_few                         |   5.2733 |   4.8534 |   1.0865 |
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
```

Round 4 (same as round 1):

```
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
join_dataframe_index_single_key_small        |   6.4983 |   5.9470 |   1.0927 |
frame_reindex_columns                        |   0.3057 |   0.2790 |   1.0954 |
strings_contains_many                        |   5.3923 |   4.8310 |   1.1162 |
eval_frame_and_python                        |  44.8277 |  38.6840 |   1.1588 |
panel_shift_minor                            |   0.1193 |   0.0870 |   1.3708 |
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
```

i think this is ok, just variability rearing its ugly head

yep
anytime I change key code I give a check