BUG: Pandas does not recognise older missing value code for double when reading Stata files prior to 108 (Stata 6) format #58149
Labels
Bug
IO Stata
read_stata, to_stata
Needs Triage
Issue that has not been reviewed by a pandas team member
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Stata format 108 (corresponding to Stata 6) changed the code used to signify a missing value of type double (from 2^333 [1] to 2^1023 [2]). Pandas does not currently recognise this when reading these Stata file versions and therefore leaves the raw value in the DataFrame (note that the missing code for float types has not changed and therefore this works as expected):
The test file used above is \sg99\dta\aidsdata.dta contained in https://web.archive.org/web/19991011204243/http://lib.stat.cmu.edu/stata/STB/stb47v5.zip
References:
[1] Stata 1 reference manual, page 5 (https://www.statalist.org/forums/forum/general-stata-discussion/general/1638352-stata-1-reference-manual-now-available-to-anyone-who-wants-it)
[2] Description of the .dta file format 108, Representation of numbers (dta_108.txt)
Expected Behavior
I would expect the data displayed to match that in Stata:
Installed Versions
INSTALLED VERSIONS
commit : bdc79c1
python : 3.12.2.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United Kingdom.1252
pandas : 2.2.1
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 69.2.0
pip : 24.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 5.1.0
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.3
numba : None
numexpr : 2.9.0
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.12.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: