Skip to content

fix: feature group should ignore nan values #2169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sagemaker/feature_store/feature_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def _ingest_single_batch(
feature_name=data_frame.columns[index], value_as_string=str(row[index])
)
for index in range(len(row))
if pd.notna(row[index])
]
sagemaker_session.put_record(
feature_group_name=feature_group_name, record=[value.to_dict() for value in record]
Expand Down
5 changes: 5 additions & 0 deletions tests/integ/test_feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def pandas_data_frame():
"feature1": pd.Series(np.arange(10.0), dtype="float64"),
"feature2": pd.Series(np.arange(10), dtype="int64"),
"feature3": pd.Series(["2020-10-30T03:43:21Z"] * 10, dtype="string"),
"feature4": pd.Series(np.arange(5.0), dtype="float64"), # contains nan
}
)
return df
Expand Down Expand Up @@ -132,6 +133,7 @@ def create_table_ddl():
" feature1 FLOAT\n"
" feature2 INT\n"
" feature3 STRING\n"
" feature4 FLOAT\n"
" write_time TIMESTAMP\n"
" event_time TIMESTAMP\n"
" is_deleted BOOLEAN\n"
Expand Down Expand Up @@ -214,6 +216,9 @@ def test_create_feature_store(
time.sleep(60)

assert df.shape[0] == 11
nans = pd.isna(df.loc[df["feature1"].isin([5, 6, 7, 8, 9])]["feature4"])
for is_na in nans.items():
assert is_na
assert (
create_table_ddl.format(
feature_group_name=feature_group_name,
Expand Down