alteryx / alteryx/woodwork

Boolean type conversion does not get called

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

Beschreibung

If a user supplies specific `variable_types` for a Boolean variable that has an underlying "object" dtype, and that include type information as kwargs, the associated logic in `Entity.entityset_convert_variable_type` does not get called. This is because Booleans are a subclass of Discrete, and the "object" dtype is in "_categorical_types".

Relevant code is in `Entity.convert_variable_types()`.

What this means is that if I have a dataframe with a string column that I call a Boolean:

```
df = pd.DataFrame({'boolean': ['y', 'n', 'y'], 'id': [0,1,2]})
variable_types .= {'boolean': (ft.variable_types.Boolean, {'true_val': 'y', 'false_val': 'n'})}
es.entity_from_dataframe('test', df, index='id', variable_types=variable_types)
```

The column remains a string, does not get converted to a Boolean, and so features like `PercentTrue` fail because they expect boolean inputs.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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