Skip to content

fix: use iterrows to iterate pandas dataframe #2011

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 4 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/sagemaker/feature_store/feature_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ def _ingest_single_batch(
end_index (int): ending position to ingest in this batch.
"""
logger.info("Started ingesting index %d to %d", start_index, end_index)
for row in data_frame[start_index:end_index].itertuples(index=False):
for _, row in data_frame[start_index:end_index].iterrows():
record = [
FeatureValue(feature_name=name, value_as_string=str(value))
for name, value in row._asdict().items()
for name, value in row.items()
]
sagemaker_session.put_record(
feature_group_name=feature_group_name, record=[value.to_dict() for value in record]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/sagemaker/feature_store/test_feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_load_feature_definition_unsupported_types(sagemaker_session_mock):
@patch("sagemaker.feature_store.feature_group.IngestionManagerPandas")
def test_ingest(ingestion_manager_init, sagemaker_session_mock):
feature_group = FeatureGroup(name="MyGroup", sagemaker_session=sagemaker_session_mock)
df = pd.DataFrame({"float": pd.Series([2.0], dtype="float64")})
df = pd.DataFrame(dict((f"float{i}", pd.Series([2.0], dtype="float64")) for i in range(300)))

mock_ingestion_manager_instance = Mock()
ingestion_manager_init.return_value = mock_ingestion_manager_instance
Expand Down