Repository navigation
Conversation
pandas.read_csv treats strings such as N/A, NA, NULL and nan as missing values by default. CSVDocumentSplitter therefore emptied those cells in its output, and a row made only of such values was treated as an empty row and used as a split boundary. Read CSV content with keep_default_na=False and na_values=[""] so that only genuinely empty fields count as missing. Callers can still override both options through read_csv_kwargs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
@vidigoat is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
|
Verified locally: the full |
This branch has not been deployed
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.
Related Issues
CSVDocumentSplitterhalf. TheCSVDocumentCleanerhalf is covered by fix: preserve literal NA values in CSVDocumentCleaner #12772, so this PR intentionally doesn't auto-close the issue.Proposed Changes:
CSVDocumentSplitterparses each document withpandas.read_csv, which by default treats literal strings such asN/A,NA,NULL, andnanas missing values (dtype=objectdoes not prevent this). As a result:A1,N/A,keepbecomesA1,,keep);thresholdmode, a row made only of such values is treated as an empty row, used as a split boundary, and dropped from the output.This PR adds
keep_default_na=Falseandna_values=[""]to the splitter's defaultread_csv_kwargs, placed before the caller's kwargs so an explicit override still wins.na_values=[""]is what keeps genuinely empty fields parsed as NaN, so empty-row/column detection and splitting behave exactly as before. This is the combination @julian-risch pointed to when closing #12806 ("disabling pandas' default NA parsing without re-adding empty-string detection breaks the handling of empty rows and columns"), and the same one #12772 uses for the cleaner.Also updated the
read_csv_kwargsdocstring (listing the new defaults) and added one sentence todocs-website/docs/pipeline-components/preprocessors/csvdocumentsplitter.mdxsaying what counts as an empty row or column.How did you test it?
main(c6c46c67b) with the issue's inputs: row-wise output was['Code,Status,Note\n', 'A1,,keep\n', 'A2,,keep\n', 'A3,,keep\n']; threshold mode onCode,Status\nA1,ok\nN/A,N/A\nA3,ok\nreturned['Code,Status\nA1,ok\n', 'A3,ok\n'](theN/A,N/Arow was lost). With this change the cells are preserved, the input comes back as one table, and a genuinely empty,row still splits.test/components/preprocessors/test_csv_document_splitter.py:test_literal_na_strings_are_kept_as_cell_content(row-wise mode)test_row_of_literal_na_strings_is_not_a_split_boundary(threshold mode; the same input also contains a real empty row, which must still split, and the test checksrow_idx_start)Both fail with the fix reverted (2 failed, 29 passed) and pass with it.
hatch run test:unit test/components/preprocessors/test_csv_document_splitter.py: 31 passedhatch run test:unit test/components/preprocessors/ test/components/converters/test_csv_to_document.py: 488 passedhatch run fmt-check: passed;hatch run test:types: no issues in 562 source files;reno lint .: passed;pre-commit run --files <changed files>: all hooks passedread_csv_kwargs={"keep_default_na": True}restores the previous behavior (mentioned in the release note).Notes for the reviewer
N/A/NULLcells being blanked by the splitter will now see them as content. The release note says how to get the old behavior back.na_valuesinread_csv_kwargswithout also settingkeep_default_na, only their values (no longer pandas' default list) are treated as missing. That follows from the documented "extend or override" semantics ofread_csv_kwargs.This PR was developed with Claude Code (AI) on my behalf. The regression tests fail on
mainand pass with this change, and the checks listed above pass locally.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.