fix(excel): remove unwanted index column from Excel exports#38176
fix(excel): remove unwanted index column from Excel exports#38176
Conversation
The Excel export was including an unwanted index column because `df.to_excel()` defaults to `index=True`. CSV export already handled this correctly by passing `index=include_index`. This fix applies the same logic to Excel exports: only include the index column if the DataFrame has a custom index (not a RangeIndex). Closes #32113 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review Agent Run #41d749Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Update Excel export tests to expect the new index=False argument passed to df_to_excel() which removes the unwanted index column. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review Agent Run #00e019Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> (cherry picked from commit c4eb7de)
Summary
The Excel export was including an unwanted index column (row numbers 0, 1, 2...) because
df.to_excel()defaults toindex=True. CSV export already handled this correctly by passingindex=include_index.This fix applies the same logic to Excel exports: only include the index column if the DataFrame has a custom index (not a RangeIndex).
Before:

After: The first column with row numbers will no longer appear.
Test plan
Closes #32113
Related: #22981, #29717
🤖 Generated with Claude Code