Woodwork Incorrectly Infers Boolean
- Ngôn ngữ chính
- Python
- Star
- 155
- Fork
- 24
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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)
```
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.