Woodwork Incorrectly Infers Boolean
- Lenguaje dominante
- Python
- Estrellas
- 155
- Forks
- 24
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I would expect the following test to pass. We're seeing within `concat_columns` that when a DataFrame with a column with mixed null/integers is passed the `Integer` logical type during inference, the `init` fails. This is expected and an MR was put up to make `concat_columns` resilient to this. When we extended the test to cover Boolean/BooleanNullable, it was discovered that the `init` will impute the missing boolean value rather than error out that there was an attempted coercion to a non-nullable type.
I would expect that the following test would pass and also be extendable to Integer/IntegerNullable (and float64/Float64 when they're a thing).
```python
import pytest
import numpy as np
@pytest.mark.parametrize("none_type", [None, np.nan, pd.NA])
@pytest.mark.parametrize("pass_logical_types", [True, False])
def test_boolean_inference(none_type, pass_logical_types):
df = pd.DataFrame({"boolean": [none_type, True, False, True]})
if pass_logical_types:
with pytest.raises(Exception):
# Would expect init to fail as you're trying to coerce a boolean to bool.
df.ww.init(logical_types = {"boolean": Boolean})
else:
df.ww.init()
assert isinstance(df.ww.logical_types["boolean"], BooleanNullable)
```
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.