Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
BUG: Printing of a pandas Series of complex numbers with e-notation has broken between 2.0.x and older versions and the newer 2.1.x, 2.2.x versions #60393
We use the pandas Series method to store a list of complex numbers but when upgrading from the pandas 1.3, 1.5, or 2.0 versions we are seeing a regression issue where in pandas 2.1.x and 2.2.x and latest 2.2.3 version the print out is adding extra white space to the imaginary value's e-notation portion.
example:
import pandas as pdinput_array = [(1.8816e-09+0j), (3.39676e-09+0j)]print("input_array=\n", input_array)print("pd.Series(input_array)=\n", pd.Series(input_array))
For example in pandas 1.3, 1.5, 2.0.3 we see the following output that we expect from the following example:
But now in pandas version 2.1.x, 2.2.x, and latest 2.2.3 we are getting the output instead:
input_array=[(1.8816e-09+0j), (3.39676e-09+0j)]pd.Series(input_array)=0 1.881600e-09+0.000000e+ 00j1 3.396760e-09+0.000000e+ 00jdtype: complex128
Thanks.
Expected Behavior
The expected output is the following:
input_array=[(1.8816e-09+0j), (3.39676e-09+0j)]pd.Series(input_array)=0 1.881600e-09+0.000000e+00j1 3.396760e-09+0.000000e+00jdtype: complex128
Where the +0j portion of the complex value is printed as +0.000000e+00j
not what it is printed now as: 0.000000e+ 00j
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
We use the pandas Series method to store a list of complex numbers but when upgrading from the pandas 1.3, 1.5, or 2.0 versions we are seeing a regression issue where in pandas 2.1.x and 2.2.x and latest 2.2.3 version the print out is adding extra white space to the imaginary value's e-notation portion.
example:
import pandas as pd
input_array = [(1.8816e-09+0j), (3.39676e-09+0j)]
print("input_array=\n", input_array)
print("pd.Series(input_array)=\n", pd.Series(input_array))
For example in pandas 1.3, 1.5, 2.0.3 we see the following output that we expect from the following example:
input_array=
[(1.8816e-09+0j), (3.39676e-09+0j)]
pd.Series(input_array)=
0 1.881600e-09+0.000000e+00j
1 3.396760e-09+0.000000e+00j
dtype: complex128
But now in pandas version 2.1.x, 2.2.x, and latest 2.2.3 we are getting the output instead:
input_array=
[(1.8816e-09+0j), (3.39676e-09+0j)]
pd.Series(input_array)=
0 1.881600e-09+0.000000e+ 00j
1 3.396760e-09+0.000000e+ 00j
dtype: complex128
Thanks.
Expected Behavior
The expected output is the following:
input_array=
[(1.8816e-09+0j), (3.39676e-09+0j)]
pd.Series(input_array)=
0 1.881600e-09+0.000000e+00j
1 3.396760e-09+0.000000e+00j
dtype: complex128
Where the
+0j
portion of the complex value is printed as+0.000000e+00j
not what it is printed now as:0.000000e+ 00j
Installed Versions
Thanks