Repository navigation
fix(probe_data): support pandas 3 StringDtype in CSV prompt column fallback - #398
Merged
Merged
Conversation
Owner
|
@brixtonpham thx for the patch! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this changes
Fixes the text-column fallback in
parse_csv_content()(agentic_security/probe_data/data.py), which broke on pandas 3.0 (pandas==3.0.6inpoetry.lock) becausepd.read_csv()now infers text columns asStringDtype(str) rather thanobject, causingdf[col].dtype == objectto evaluate toFalsefor every text column:_is_non_empty_text_column(series)usingpd.api.types.is_string_dtype(non_null)afterdropna()plus a non-blank check — works on both pandas 3.0StringDtypeand pandas 2.x stringobjectcolumns, skips all-null/whitespace-only columns, and avoids mis-selecting nullable booleanobjectcolumns (flag,textwith missing booleans)."prompt"first, then case-insensitive/trimmed"prompt"(e.g.,Prompt), then the first non-empty text column, preservingValueErrorfor numeric-only, boolean-only, or empty CSVs.tests/unit/probe_data/test_parse_csv_content.py.How it was tested
pytest -v tests/unit/probe_data/ agentic_security/probe_data/test_data.py tests/integration/routes/test_csv.pyon Python 3.15.2 /pandas 3.0.6: 52 passed (including all 14 new cases intest_parse_csv_content.py)..pre-commit-config.yaml(black --check,flake8,pyupgrade --py314-plus,pycln --check,codespell,poetry check --lock): all clean.Checklist
pytestpasses and new behaviour has a test. Tests don't call paid APIs.pre-commit run --all-filesis clean.