Skip to content

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
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.

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

1 participant