Skip to content

BUG: Fix to_html adding time to datetime columns in transposed DataFrame (GH#10640)#63400

Closed
epabarker wants to merge 1 commit intopandas-dev:mainfrom
epabarker:fix-10640-to-html-datetime-header
Closed

BUG: Fix to_html adding time to datetime columns in transposed DataFrame (GH#10640)#63400
epabarker wants to merge 1 commit intopandas-dev:mainfrom
epabarker:fix-10640-to-html-datetime-header

Conversation

@epabarker
Copy link

Description:
When using to_html on a transposed DataFrame with a DatetimeIndex, the column headers were including the time component (e.g., 00:00:00) even when it should be hidden. This was because HTMLFormatter was using the raw column values instead of the formatted values.

Fix:

  • Updated HTMLFormatter._get_columns_formatted_values to use self.columns._format_flat(include_name=False), aligning the behavior with NotebookFormatter and respecting display options.

Verification:

  • Added regression test test_to_html_datetime_columns_no_time in pandas/tests/io/formats/test_to_html.py.
  • Added release note in doc/source/whatsnew/v3.0.0.rst.

@epabarker epabarker marked this pull request as draft December 17, 2025 16:25
@epabarker epabarker force-pushed the fix-10640-to-html-datetime-header branch from 05cf151 to 263b99a Compare December 17, 2025 16:27
@epabarker epabarker force-pushed the fix-10640-to-html-datetime-header branch from 263b99a to 61ece3b Compare December 17, 2025 16:36
@epabarker epabarker marked this pull request as ready for review December 17, 2025 16:46
@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Jan 17, 2026
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When transposing a datetime index without time and using to_html, time is added to column titles.

2 participants