Skip to content

docs: document that XLSXToDocument row numbering assumes the pandas positional index - #13566

Merged
anakin87 merged 2 commits into
deepset-ai:mainfrom
Smilewithoutfalling:fix/xlsx-index-col-preserved
Nov 5, 2026
Merged

anakin87 merged 2 commits into
deepset-ai:mainfrom
Smilewithoutfalling:fix/xlsx-index-col-preserved

Conversation

@Smilewithoutfalling

@Smilewithoutfalling Smilewithoutfalling commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Related Issues

  • N/A

Proposed Changes

XLSXToDocument numbers the rows of the output table from 1 so that they match the Excel row numbers:

df.index = df.index + 1

That only holds when pandas assigns the positional index. Supporting every combination of read_excel_kwargs in the converter is out of scope, so this documents the limitation in the read_excel_kwargs docstring instead, following the CSVDocumentSplitter wording.

The added paragraph states that:

  • options that shift the rows or replace the index, such as skiprows or index_col, make the numbering inaccurate;
  • a source whose index_col holds non-numeric values is skipped;
  • the conversion output should be validated on representative inputs when these options are customized.

Behavior is unchanged — the diff is docstring only.

How did you test it?

No behavior change, so no new test. I checked that the documented behavior is what main actually does:

input result
index_col on a string column 0 documents, warning can only concatenate str (not "int") to str
index_col on a numeric column with a header row 0 documents, same warning (the header text lands in the index)
index_col on a numeric column without a header row rows renumbered 101, 102 → 102, 103
skiprows=2 rows numbered from 1 instead of the Excel row numbers 3, 4

ruff check and ruff format --check report the same results as on unmodified main for this file.

Notes for the reviewer

  • Dropped the test and the release note from the earlier revision; the branch is now a single docstring commit based on 0de7bcdc.
  • The index_col failure above is a separate pre-existing defect. Happy to send a follow-up that guards only that case if you'd rather fix it than document it.

Checklist

@Smilewithoutfalling
Smilewithoutfalling requested a review from a team as a code owner November 5, 2026 06:54
@Smilewithoutfalling
Smilewithoutfalling requested review from anakin87 and removed request for a team November 5, 2026 06:54
@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@Smilewithoutfalling is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Smilewithoutfalling
Smilewithoutfalling force-pushed the fix/xlsx-index-col-preserved branch 2 times, most recently from 2075ff9 to aa5e359 Compare November 5, 2026 07:17
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

@anakin87 anakin87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello and thank you!

I think that supporting every possible combination of read_excel_kwargs is out of scope, so I'd suggest simply improving the docstring to communicate the limitations, similarly to

:param read_csv_kwargs: Keyword arguments passed to `pandas.read_csv`.
These extend or override the following defaults:
- `header=None`
- `skip_blank_lines=False` to preserve blank lines
- `dtype=object` to prevent type inference (e.g., converting numbers to floats).
See https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html for more information.
Customizing CSV parsing options may cause splitting errors or inaccurate position metadata.
Validate the split content and metadata on representative inputs when customizing these options.

…ositional index

`XLSXToDocument` numbers the rows of the output table from 1 so that they match the Excel row
numbers, which only holds when pandas assigns the positional index. Supporting every combination
of `read_excel_kwargs` in the converter is out of scope, so the limitation is documented in the
`read_excel_kwargs` docstring instead, following the `CSVDocumentSplitter` wording.

The paragraph names the two effects that matter: options such as `skiprows` or `index_col` make the
numbering inaccurate, and a source whose `index_col` holds non-numeric values is skipped. No
behavior change.
@Smilewithoutfalling
Smilewithoutfalling force-pushed the fix/xlsx-index-col-preserved branch from aa5e359 to 6534647 Compare November 5, 2026 13:11
@Smilewithoutfalling Smilewithoutfalling changed the title fix: keep the DataFrame index as read when XLSXToDocument uses index_col docs: document that XLSXToDocument row numbering assumes the pandas positional index Nov 5, 2026
@Smilewithoutfalling

Copy link
Copy Markdown
Contributor Author

Thanks for the review — reverted the index_col guard and made this docstring-only: the test and the release note are gone, and the limitation is now documented in the read_excel_kwargs docstring following the CSVDocumentSplitter wording.

One thing worth knowing while writing that paragraph: with index_col the failure is harder than inaccurate numbering. df.index = df.index + 1 raises TypeError when the index holds non-numeric values (can only concatenate str (not "int") to str), run() catches it and skips the source, so the conversion returns 0 documents. That also hits a numeric index_col when a header row is present, because the converter reads with header=None and the header text ends up in the index. I documented it as "the source is skipped" rather than as a numbering inaccuracy.

If you'd rather fix that one case than document it, I can open a follow-up that guards only index_col.

@github-actions github-actions Bot added the type:documentation Improvements on the docs label Nov 5, 2026
@anakin87
anakin87 enabled auto-merge (squash) November 5, 2026 14:07
@anakin87
anakin87 merged commit d31b847 into deepset-ai:main Nov 5, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants