Display precision doesn't affect complex float numbers · Issue #25514 · pandas-dev/pandas (original) (raw)

Code Sample

import numpy as np import pandas as pd

pd.set_option("display.precision", 3)

A = np.random.rand(3,3) df_A = pd.DataFrame(A)

B = np.random.rand(3,3)+1j*np.random.rand(3,3) df_B = pd.DataFrame(B)

print(df_A) print(df_B)

Output:

    0      1      2
0  0.665  0.824  0.953
1  0.341  0.078  0.408
2  0.945  0.411  0.078
                                            0  \
0    (0.2553045397887609+0.8464631779709604j)   
1  (0.5724405361700162+0.047300152111596105j)   
2     (0.5824766758024993+0.974755917539835j)   

                                           1  \
0  (0.3533797280121552+0.20515824034905894j)   
1    (0.928312255311234+0.3909443194373995j)   
2   (0.2700966337410404+0.9137483492310767j)   

                                           2  
0  (0.21748538025578568+0.7730350615682122j)  
1  (0.2435709287109903+0.46366472945887327j)  
2   (0.6531622218102532+0.5102462678094016j)

Problem description

Display precision (pd.set_option("display.precision", 3)) doesn't affect complex float numbers like shown in the example.

Expected Output

    0      1      2
0  0.665  0.824  0.953
1  0.341  0.078  0.408
2  0.945  0.411  0.078

               0               1               2
0   0.976+0.935j    0.739+0.851j    0.436+0.734j
1   0.998+0.867j    0.774+0.849j    0.553+0.749j
2   0.405+0.049j    0.965+0.912j    0.292+0.958j

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 39.0.1
Cython: 0.29
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.1.1
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: None
numexpr: None
feather: None
matplotlib: 3.0.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None