Skip to content

read_sas floating point error (SAS version 6) #30051

Closed
@blumdrew

Description

@blumdrew

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).

df1 = pd.read_sas('fname.xpt')
df1['column_1']
0 5.397605e-79
1 5.397605e-79
2 5.397605e-79
3 5.397605e-79
4 5.397605e-79
...
423663 8.000000e+01
423664 8.000000e+01
423665 8.000000e+01
423666 8.000000e+01
423667 8.000000e+01
Name: column_1, Length: 423668, dtype: float64

Here is the same file read in with the xport (https://github.com/selik/xport) "to_dataframe"

with open('fname.xpt', 'rb') as f:
df = xport.to_dataframe(f)
df['column_1']
0 0.0
1 0.0
2 0.0
3 0.0
4 0.0
...
423663 80.0
423664 80.0
423665 80.0
423666 80.0
423667 80.0
Name: column_1, Length: 423668, dtype: float64

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions