Repository navigation
fix: keep missing text values None under pandas 3 #1149
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
andreatnvidia
merged 2 commits into
main
from
yev/fix/1146-person-sampler-missing-values
Nov 10, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/data-designer/tests/interface/test_missing_values.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import pandas as pd | ||
| import pytest | ||
|
|
||
| from data_designer.config.column_configs import CustomColumnConfig, ExpressionColumnConfig | ||
| from data_designer.config.config_builder import DataDesignerConfigBuilder | ||
| from data_designer.config.custom_column import custom_column_generator | ||
| from data_designer.config.models import ModelProvider | ||
| from data_designer.config.run_config import RunConfig | ||
| from data_designer.config.seed_source_dataframe import DataFrameSeedSource | ||
| from data_designer.engine.secret_resolver import PlaintextResolver | ||
| from data_designer.interface.data_designer import DataDesigner | ||
|
|
||
|
|
||
| @custom_column_generator(required_columns=["value"]) | ||
| def flag_missing_value(row: dict[str, Any]) -> dict[str, Any]: | ||
| return {**row, "flag": "MISSING" if row["value"] is None else "PRESENT"} | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("run", ["preview", "create"]) | ||
| def test_a_missing_seed_text_value_reaches_templates_and_generators_as_none( | ||
| tmp_path: Path, stub_model_providers: list[ModelProvider], run: str | ||
| ) -> None: | ||
| managed = tmp_path / "managed" | ||
| managed.mkdir() | ||
| designer = DataDesigner( | ||
| artifact_path=tmp_path / "artifacts", | ||
| model_providers=stub_model_providers, | ||
| secret_resolver=PlaintextResolver(), | ||
| managed_assets_path=managed, | ||
| ) | ||
| designer.set_run_config(RunConfig(otel_metrics_port=None)) | ||
| config = DataDesignerConfigBuilder().with_seed_dataset( | ||
| DataFrameSeedSource(df=pd.DataFrame({"value": ["present", None, ""]})) | ||
| ) | ||
| config.add_column( | ||
| ExpressionColumnConfig(name="rendered", expr="{{ 'MISSING' if value is none else 'PRESENT' }}", dtype="str") | ||
| ) | ||
| config.add_column(CustomColumnConfig(name="flag", generator_function=flag_missing_value)) | ||
|
|
||
| if run == "preview": | ||
| dataset = designer.preview(config, num_records=3).dataset | ||
| else: | ||
| dataset = designer.create(config, num_records=3, dataset_name="missing_values").load_dataset() | ||
|
|
||
| assert dataset["rendered"].tolist() == ["PRESENT", "MISSING", "PRESENT"] | ||
| assert dataset["flag"].tolist() == ["PRESENT", "MISSING", "PRESENT"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PeopleGenFromDataset.generatenow leaves missing numeric fields as NaN. The removed loop converted missing values in every column, butdataframe_to_recordsonly converts text/object columns. If a managed dataset has a partly empty numeric field such asmonthly_income_eur, sampled people receive NaN instead ofNone. Saving that person column withstorage_encoding='json'then fails because JSON storage rejects non-finite numbers.Keep the all-column conversion for person records while leaving the shared helper's numeric behavior unchanged.
Knowledge Base Used: Sampling and synthetic generation
Prompt To Fix With AI