Skip to content
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

IndexError in repr of series objects containing complex numbers with negative imaginary parts #27484

DRMacIver opened this issue Jul 19, 2019 · 1 comment


Copy link

@DRMacIver DRMacIver commented Jul 19, 2019

Code Sample, a copy-pastable example if possible

from pandas import Series


Problem description

This raises the following error:

Traceback (most recent call last):
  File "", line 3, in <module>
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/core/", line 1611, in __repr__
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/core/", line 1677, in to_string
    result = formatter.to_string()
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 312, in to_string
    fmt_values = self._get_formatted_values()
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 299, in _get_formatted_values
    values_to_format, None, float_format=self.float_format, na_rep=self.na_rep
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1032, in format_array
    return fmt_obj.get_result()
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1063, in get_result
    fmt_values = self._format_strings()
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1288, in _format_strings
    return list(self.get_result_as_array())
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1252, in get_result_as_array
    formatted_values = format_values_with(float_format)
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1234, in format_values_with
    return _trim_zeros_complex(values, na_rep)
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1597, in _trim_zeros_complex
    return ["".join(separate_and_trim(x, na_rep)) for x in str_complexes]
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1597, in <listcomp>
    return ["".join(separate_and_trim(x, na_rep)) for x in str_complexes]
  File "/home/david/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/io/formats/", line 1594, in separate_and_trim
    + ["j"]
IndexError: list index out of range

Expected Output

This should print something like the following:

0    0.0-1.0j
dtype: complex128

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]


commit : None
python :
python-bits : 64
OS : Linux
OS-release : 4.4.0-17134-Microsoft
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8

pandas : 0.25.0
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.0.3
setuptools : 40.8.0
Cython : None
pytest : 5.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.6.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

Copy link

@mroeschke mroeschke commented Jul 19, 2019

PR #25745 is probably the culprit for this regression. Investigation and PR's welcome!


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants