@@ -892,9 +892,7 @@ def format_array(values, formatter, float_format=None, na_rep='NaN',
892
892
fmt_klass = Timedelta64Formatter
893
893
elif is_extension_array_dtype (values .dtype ):
894
894
fmt_klass = ExtensionArrayFormatter
895
- elif is_float_dtype (values .dtype ):
896
- fmt_klass = FloatArrayFormatter
897
- elif is_complex_dtype (values .dtype ):
895
+ elif is_float_dtype (values .dtype ) or is_complex_dtype (values .dtype ):
898
896
fmt_klass = FloatArrayFormatter
899
897
elif is_integer_dtype (values .dtype ):
900
898
fmt_klass = IntArrayFormatter
@@ -1100,7 +1098,7 @@ def format_values_with(float_format):
1100
1098
if is_complex :
1101
1099
return _trim_zeros_complex (values , na_rep )
1102
1100
else :
1103
- return _trim_zeros (values , na_rep )
1101
+ return _trim_zeros_float (values , na_rep )
1104
1102
1105
1103
return values
1106
1104
@@ -1433,19 +1431,19 @@ def just(x):
1433
1431
def _trim_zeros_complex (str_complexes , na_rep = 'NaN' ):
1434
1432
"""
1435
1433
Separates the real and imaginary parts from the complex number, and
1436
- executes the _trim_zeros method on each of those.
1434
+ executes the _trim_zeros_float method on each of those.
1437
1435
"""
1438
1436
def separate_and_trim (str_complex , na_rep ):
1439
1437
num_arr = str_complex .split ('+' )
1440
- return (_trim_zeros ([num_arr [0 ]], na_rep ) +
1438
+ return (_trim_zeros_float ([num_arr [0 ]], na_rep ) +
1441
1439
['+' ] +
1442
- _trim_zeros ([num_arr [1 ][:- 1 ]], na_rep ) +
1440
+ _trim_zeros_float ([num_arr [1 ][:- 1 ]], na_rep ) +
1443
1441
['j' ])
1444
1442
1445
1443
return ['' .join (separate_and_trim (x , na_rep )) for x in str_complexes ]
1446
1444
1447
1445
1448
- def _trim_zeros (str_floats , na_rep = 'NaN' ):
1446
+ def _trim_zeros_float (str_floats , na_rep = 'NaN' ):
1449
1447
"""
1450
1448
Trims zeros, leaving just one before the decimal points if need be.
1451
1449
"""
0 commit comments