alteryx / alteryx/woodwork

Woodwork Incorrectly Infers Boolean

未关闭
#1,486 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Python
星标
155
派生
24
PR 合并指标
30 天内没有已合并 PR

描述

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)

```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。