Skip to content

Commit 15409f8

Browse files
committed
Move definition of the old missing value constant for the double type out of the loop
1 parent 6f20675 commit 15409f8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/io/stata.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,15 +1817,17 @@ def read(
18171817
return data
18181818

18191819
def _do_convert_missing(self, data: DataFrame, convert_missing: bool) -> DataFrame:
1820+
# missing code for double was different in version 105 and prior
1821+
old_missingdouble = float.fromhex("0x1.0p333")
1822+
18201823
# Check for missing values, and replace if found
18211824
replacements = {}
18221825
for i in range(len(data.columns)):
18231826
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
1827+
# recode instances of the old missing code to the currently used value
18261828
if self._format_version <= 105 and fmt == "d":
18271829
data.iloc[:, i] = data.iloc[:, i].replace(
1828-
float.fromhex("0x1.0p333"), self.MISSING_VALUES["d"]
1830+
old_missingdouble, self.MISSING_VALUES["d"]
18291831
)
18301832

18311833
if self._format_version <= 111:

0 commit comments

Comments
 (0)