Skip to content

BUG: fix to_csv chunksize producing inconsistent dt64/td64 formatting#65183

Draft
jbrockmendel wants to merge 4 commits intopandas-dev:mainfrom
jbrockmendel:bug-55481
Draft

BUG: fix to_csv chunksize producing inconsistent dt64/td64 formatting#65183
jbrockmendel wants to merge 4 commits intopandas-dev:mainfrom
jbrockmendel:bug-55481

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

Summary

  • Fixes inconsistent datetime and timedelta formatting in DataFrame.to_csv when chunksize causes columns to be formatted chunk-by-chunk instead of using the full column data
  • Pre-computes _is_dates_only for each datetime/timedelta column using the full column before chunking, and pre-formats the index when it is a DatetimeIndex/TimedeltaIndex
  • Adds 6 tests covering datetime columns, timedelta columns, datetime index, multiple datetime columns, dates-only preservation, and chunked-vs-default equivalence

closes #55481

Test plan

  • Existing CSV tests pass (672 total)
  • mypy and pyright clean on modified file
  • pre-commit passes
  • New tests cover: datetime column, timedelta column, datetime index, multiple datetime columns with mixed dates-only, dates-only preservation, and chunked vs non-chunked equivalence

🤖 Generated with Claude Code

jbrockmendel and others added 2 commits April 17, 2026 15:21
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.

BUG: to_csv with chunksize mismatched formatting of dt64

1 participant