alteryx / alteryx/woodwork

Add automatic fallback to nullable logical types

Ouverte
#1,119 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
featuretools new feature
Langage dominant
Python
Étoiles
155
Forks
24
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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']
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.