alteryx / alteryx/woodwork

Add automatic fallback to nullable logical types

Open
#1,119 2 comments 0 reactions 0 assignees View on GitHub
featuretools new feature
Dominant language
Python
Stars
155
Forks
24
PR merge metrics
No merged PRs in 30d

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.