Repository navigation
fix(dtypes): the report no longer calls a datetime parse "converted to object" - #508
Merged
Merged
Conversation
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
…o object"
A column of datetime strings carrying different UTC offsets -- the ordinary
result of a DST changeover or of merging exports from two regions -- is
parsed cell by cell into timestamps that each keep their own offset. No
single datetime64 dtype can hold several offsets, so pandas returns them in
an object column. The parse is faithful and lossless, but fix_dtypes built
its description from the dtype alone and recorded "converted to object", risk
low -- which reads as though nothing was converted.
The description now says what happened ("parsed to timestamps; kept as
object because the values carry different UTC offsets, so no single
datetime64 dtype can hold them", or "... mix timezone-aware and
timezone-naive timestamps"), and the coercion warning says "could not be
parsed as timestamps" instead of "as object". Report text only: cell values,
dtypes, risk and confidence are unchanged (checked byte-for-byte against
main over 12 cases), as is every other column's description.
The "after semantic repair" sibling description cannot receive such a column
(refine_numeric_after_semantic only produces real numeric dtypes); a test
pins that.
tests/test_mixed_offset_audit_record.py: 20 tests. With the updated
threshold test, 12 fail without this change on both py3.12/pandas 2.3.3 and
py3.9/pandas 1.5.3.
kevincostner17
force-pushed
the
fix/fd2015-audit-record
branch
from
September 28, 2026 18:29
a41a471 to
61e7f3d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
A column of datetime strings with different UTC offsets is common: a daylight-saving changeover, or exports from two regions merged together.
fd.cleanparses it correctly, cell by cell, into timestamps that each keep their own offset. No singledatetime64dtype can hold several offsets, so pandas returns them in anobjectcolumn. The data is right. The audit record is wrong:Read plainly, "converted to object" says nothing was converted, when every cell was in fact parsed to a timestamp.
fix_dtypesbuilt the description from the resulting dtype alone and ignored the conversion target.Fix
The description now says what happened:
A column mixing timezone-aware and naive values takes the same path; it gets its own reason: "… mix timezone-aware and timezone-naive timestamps …". The coercion warning for such a column now says "could not be parsed as timestamps" rather than "as object". The existing
(N unparseable value(s) set to missing)suffix is unchanged.Report text only. Cell values, dtypes, risk and confidence are unchanged, and were checked byte-for-byte against
mainover 12 cases on both interpreters. Every other column keeps itsconverted to <dtype>description, including single-offset and naive datetime columns.The sibling
"converted to … after semantic repair"description cannot receive such a column, becauserefine_numeric_after_semanticonly produces real numeric dtypes. A test pins that.Tests
tests/test_mixed_offset_audit_record.py, 20 tests. Controls check that single-offset, naive, numeric and bool descriptions are exactly as before, that the cell values are unchanged, and that the unparseable suffix still appears.tests/test_dtypes_threshold_mutants.py: one test pinned the literal"converted to object". It now pins the target, dtype and casualty count instead.src/change, on both py3.12 / pandas 2.3.3 and py3.9 / pandas 1.5.3. All pass with it (3 pre-existing pandas ≥ 2 skips on py3.9).test_build_engine_cache_called_once_per_clean) is a pre-existing order-dependent test, reproduced on unmodifiedmain: it fails on py3.9 whenevertest_plugins.py::…test_import_freshdata_does_not_import_testingruns first. CI's fixed test order hides it. It is unrelated to this change.Not changed here
fd.profilestill previews such a column aswould convert to object— the same misleading text on a different surface.Compatibility impact
Report text only. Code that matched the literal
converted to objectfor such a column needs to match the new description.