Skip to content

Show a DataFrame columns.name in the index header. - #467

Open
Cherith1222 wants to merge 1 commit into
astanin:masterfrom
Cherith1222:fix/259-dataframe-columns-name
Open

Cherith1222 wants to merge 1 commit into
astanin:masterfrom
Cherith1222:fix/259-dataframe-columns-name

Conversation

@Cherith1222

Copy link
Copy Markdown

Fixes #259.

A pandas DataFrame with columns.name set and no index.name prints that columns name in the corner header. tabulate dropped it, so the header cell was blank.

columns.name is used only when index.name is missing. An explicit index name still wins. showindex=False does not print either name.

Tests, on Windows with Python 3.13 and pandas, via Resource Sentinel (1 CPU, 1.5 GiB, 1 I/O):

  • With tabulate/__init__.py checked out at upstream master, test/test_input.py -k test_pandas_columns_name_shown_when_index_unnamed failed. The header was | | a | b |.
  • On this commit the same test passed (1 passed, 33 deselected).
  • ruff 0.15.4 check and format --check passed on tabulate/__init__.py and test/test_input.py. That is the version pinned in pre-commit. A newer ruff check still reports existing findings on lines this diff does not touch; those lines were left as they are.

Not run: the full suite, an environment without pandas, and anything other than Windows.

CHANGELOG only lists released versions, so this branch does not add an entry.

Drafted with Cursor. A human has not line-reviewed the diff. There is no Co-authored-by or Signed-off-by trailer.

Pandas prints columns.name in that corner when the index has no name. Tabulate only copied index.name, so the corner stayed blank.

AI-assisted (Cursor). Not yet reviewed by a human.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(bug) : pandas.Dataframe columns.name is not displayed

1 participant