alteryx / alteryx/woodwork

Add automatic fallback to nullable logical types

未关闭
#1,119 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
featuretools new feature
主要语言
Python
星标
155
派生
24
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。