alteryx / alteryx/woodwork

Add automatic fallback to nullable logical types

Aperta
#1,119 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
featuretools new feature
Lingua principale
Python
Stelle
155
Fork
24
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

As a user, I wish Woodwork would automatically fallback to nullable types if I attempt to initialize using a non-nullable logical type on data that contains null values, raising a warning to notify me this has happened. This would be useful in situations where a null value has been added to a column or columns that did not originally have missing values and I need to reinitialize Woodwork. Adding this behavior would allow for reinitialization with an existing schema, which would fail today because the new dtypes in the modified data will be incompatible with the logical type dtypes in the schema.

#### Code Example 1

```python
import pandas as pd
import woodwork as ww

df = pd.DataFrame({'id': [0, 1, 2], 'vals': [1, 2, pd.NA]})
df.ww.init(logical_types={'vals': 'Integer'})
```

```
WoodworkInitWarning: Data for column `vals` is incompatible with logical type `Integer`. Using `IntegerNullable` instead.
```
```python
df.ww
```
```
Physical Type Logical Type Semantic Tag(s)
Column
id int64 Integer ['numeric']
vals Int64 IntegerNullable ['numeric']
```

#### Code Example 2

```python
import pandas as pd
import woodwork as ww

df = pd.DataFrame({'id': [0, 1, 2], 'vals': [1, 2, 3]})
df.ww.init()

new_df = df.ww.replace({3: pd.NA})
new_df.ww.init(schema=df.ww.schema)
```
```
WoodworkInitWarning: Data for column `vals` is incompatible with logical type `Integer`. Using `IntegerNullable` instead.
```
```python
df.ww
```
```
Physical Type Logical Type Semantic Tag(s)
Column
id int64 Integer ['numeric']
vals Int64 IntegerNullable ['numeric']
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.