Commit 0d36edf
committed
Fix accidental loss-of-precision for to_datetime(str, unit=...)
In Pandas 1.5.3, the `float(val)` cast was inline to the
`cast_from_unit` call in `array_with_unit_to_datetime`. This caused the
intermediate (unnamed) value to be a Python float.
Since #50301, a temporary variable was added to avoid multiple casts,
but with explicit type `cdef float`, which defines a _Cython_ float.
This type is 32-bit, and causes a loss of precision, and a regression in
parsing from 1.5.3.
So widen the explicit type of the temporary `fval` variable to (64-bit)
`double`, which will not lose precision.
Fixes #570511 parent 4ed67ac commit 0d36edf
File tree
3 files changed
+10
-1
lines changed- doc/source/whatsnew
- pandas
- _libs
- tests/tools
3 files changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1735 | 1735 | | |
1736 | 1736 | | |
1737 | 1737 | | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
1738 | 1746 | | |
1739 | 1747 | | |
1740 | 1748 | | |
| |||
0 commit comments