Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
>>> import pandas as pd
>>> idx = pd.Index(pd.array([1., True, 2., 3., 4]))
>>> idx.inferred_type # Wrong, should be mixed
'mixed-integer'
>>> idx = pd.Index(pd.array([1., True, 2., 3., 4.]))
>>> idx.inferred_type # Correct
'mixed'
>>> idx = pd.Index(pd.array([1, True, 2, 3, 4]))
>>> idx.inferred_type # Correct
'mixed-integer'
Issue Description
While exploring https://github.com/pandas-dev/pandas/issues/61709, I noticed this strange behavior: In case of a mixture of boolean, float and integers, the inferred type is "mixed-integer" and not "mixed"
Expected Behavior
"mixed" inferred type when there are floats, integers and booleans.
Installed Versions
Comment From: arthurlw
Confirmed on main. PRs are welcome!
Thanks for raising!
Comment From: tqa236
Look like the definition is not super clear here and changing it can touch a lot of places.
This is the current definition. I guess the implementation follows it.
- 'mixed' is the catchall for anything that is not otherwise
specialized
- 'mixed-integer-float' are floats and integers
- 'mixed-integer' are integers mixed with non-integers
I guess it should be something like this:
- 'mixed' is the catchall for anything that is not otherwise
specialized
- 'mixed-integer-float' are floats and integers and other non-integers
- 'mixed-integer' are integers mixed with non-integers but no floats
Or if we want to keep 'mixed-integer-float' to only integers and floats, we can potentially introduce a 'mixed-float': floats mixed with non-floats but no integers