-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
read_sas floating point error (SAS version 6) #30051
Comments
Sorry for the slow reply to this issue. We would need a minimal example file in order to sufficient test this locally in our continuous integration so we can confirm that this issue wouldn't appear once fixed (dummy data is fine). Going to close in the meantime, but happy to reopen if we can get a minimal example file that reproduces this behavior. |
Hello, I found the same issue analyzing NHANES data. It happens for example when I open this file https://wwwn.cdc.gov/Nchs/Nhanes/2017-2018/ALQ_J.XPT Check column ALQ121 doing: df = pd.read_sas("ALQ_J.XPT", format='xport') Possible values are 0 to 10, 77, 99 or NaN as specified here https://wwwn.cdc.gov/Nchs/Nhanes/2017-2018/ALQ_J.htm#ALQ121, so 5.397605e-79 is anomalous. |
For now I solved it doing this dirty patch df = df.replace(5.397605346934028e-79, 0) |
This issue can also be observed in the 2019 Survey of Consumer Finances when using https://www.federalreserve.gov/econres/files/scf2019x.zip After you unzip the file, you can recreate the issue as follows: import pandas as pd
everything = pd.read_sas("./scf2019x", format = 'xport')
df = everything[['X3509']]
df[df['X3509'] < 0.0001] This produces the following output:
@mroeschke : Should this ticket be reopened, or would it be better to create a new ticket? |
This would be better for a new ticket |
I've found a bug in read_sas, where on certain fields, 0.0 (floats) are read in as 5.397605e-79 (lowest IBM float value).
Here is the same file read in with the xport (https://github.com/selik/xport) "to_dataframe"
This only comes up occasionally, with a specific column in a specific file in a type of dataset that I work with. I probably will not be able to provide the example files, since these files always have proprietary information.
Let me know if there is any other information that would be useful to have.
INSTALLED VERSIONS
commit : None
python : 3.6.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 0.25.0
numpy : 1.17.0
pytz : 2019.2
dateutil : 2.8.0
pip : 9.0.1
setuptools : 28.8.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : 2.6.2
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : None
tables : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
The text was updated successfully, but these errors were encountered: