fix(xlsx): render float values faithfully instead of 6-digit scientific notation - #2533
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Conversation
XU (kokokoXUY)
left a comment
There was a problem hiding this comment.
This PR for #2532 currently contains the fenced-code whitespace change from #2529 and the DOCX heading change from #2531 as well as the XLSX float change. Both earlier PRs are still open against main. In particular, this branch still has the original fenced-code normalizer from commit b069ae1, while #2529 was updated to 7e6ed5c after review to fix the fence-boundary case. I compared the current _markitdown.py at all three PR heads: #2531 and #2533 have the same older file, and #2529 has the revised one.
Could you rebase or cherry-pick so this PR's diff against main contains only the XLSX float change and its test? That would keep the already-reviewed fence correction and the separate DOCX work from being mixed into this merge.
pandas to_html's default float format silently drops entered digits (123456789.123 -> 1.234568e+08). Pass float_format so the shortest round-tripping representation of the stored value is used. Applies to both the .xlsx and .xls paths. Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
1c27828 to
383fe6d
Compare
|
XU (@kokokoXUY) good catch, the branch had grown by stacking. rebuilt it from current main so the diff is exactly the xlsx float change and its test (383fe6d, single commit). the docx PR (#2531) had the same stacking and is rebuilt the same way (4121d96). |
|
I verified 383fe6d with pandas 2.3.3 and 3.0.5. The reported One small test improvement: the patch changes both XLSX and XLS conversion, but the committed regression only exercises XLSX. Could you add an XLS case and assert the |
|
Added the suggested test coverage on top of 383fe6d: 8936a6f (patch). Feel free to cherry-pick it. This adds the missing Both tests pass with pandas 2.3.3 and 3.0.5. Full core suite on Python 3.12: 968 passed, 43 skipped; Black 23.7.0 and diff whitespace checks pass. |
Fixes #2532.
Passes
float_formatto bothto_htmlcall sites so a float renders as the shortest string that round-trips its stored value instead of pandas' 6-significant-digit scientific notation. Integral columns keep rendering through the existing paths (the integer formatting from #2485-style handling is untouched;42.0in a genuinely-float column renders as42.0).Regression test asserts
123456789.123survives and1.234568e+08does not appear (fails on main). Existing xlsx/xls suites green (27 passed).