alteryx / alteryx/woodwork

Woodwork Incorrectly Infers Boolean

Offen
#1,486 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
155
Forks
24
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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)

```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.