Skip to content

Series of dtype float128 does not print correctly #17809

Open
@welchr

Description

@welchr

Code Sample, a copy-pastable example if possible

import numpy as np
import pandas as pd
arr = np.array(["1e-300","1e-400","1e-500"],dtype=np.float128)
s = pd.Series(arr,dtype=np.float128)

# ipython ---

# Show the values were stored correctly as float128s
In [1]: list(map(str,arr))
Out[1]: ['1e-300', '1e-400', '1e-500']

# Show the array stored in the series object still contains the correct floats
In [2]: s.values == arr
Out[2]: array([ True,  True,  True], dtype=bool)

# Printing fails, last two values should be 1e-400 and 1e-500
In [3]: print(s)
0    1.000000e-300
1     0.000000e+00
2     0.000000e+00
dtype: float128

Problem description

It seems like series are not printed correctly when using np.float128 as the dtype. Maybe the printing code uses python floats (64 bit?).

Expected Output

In [3]: print(s)
0    1.000000e-300
1     1.000000e-400
2     1.000000e-500
dtype: float128

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 36.5.0
Cython: None
numpy: 1.13.3
scipy: 0.19.1
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.0
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0b10
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: 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