Skip to content

Commit 6f20675

Browse files
committed
BUG: Missing value code not recognised for Stata format version 105 and earlier
1 parent ebc60f2 commit 6f20675

File tree

11 files changed

+36
-11
lines changed

11 files changed

+36
-11
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ I/O
584584
- Bug in :meth:`read_json` not validating the ``typ`` argument to not be exactly ``"frame"`` or ``"series"`` (:issue:`59124`)
585585
- Bug in :meth:`read_stata` raising ``KeyError`` when input file is stored in big-endian format and contains strL data. (:issue:`58638`)
586586
- Bug in :meth:`read_stata` where extreme value integers were incorrectly interpreted as missing for format versions 111 and prior (:issue:`58130`)
587+
- Bug in :meth:`read_stata` where the missing code for double was not recognised for format versions 105 and prior (:issue:`58149`)
587588

588589
Period
589590
^^^^^^

pandas/io/stata.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,13 @@ def _do_convert_missing(self, data: DataFrame, convert_missing: bool) -> DataFra
18211821
replacements = {}
18221822
for i in range(len(data.columns)):
18231823
fmt = self._typlist[i]
1824+
# missing code for double was different in version 105 and prior
1825+
# recode instances of this to the currently used value
1826+
if self._format_version <= 105 and fmt == "d":
1827+
data.iloc[:, i] = data.iloc[:, i].replace(
1828+
float.fromhex("0x1.0p333"), self.MISSING_VALUES["d"]
1829+
)
1830+
18241831
if self._format_version <= 111:
18251832
if fmt not in self.OLD_VALID_RANGE:
18261833
continue
362 Bytes
Binary file not shown.
364 Bytes
Binary file not shown.
363 Bytes
Binary file not shown.
409 Bytes
Binary file not shown.
362 Bytes
Binary file not shown.
364 Bytes
Binary file not shown.
363 Bytes
Binary file not shown.
409 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)