@@ -1382,9 +1382,9 @@ def format_values_with(float_format):
1382
1382
1383
1383
if self .fixed_width :
1384
1384
if is_complex :
1385
- result = _trim_zeros_complex (values , na_rep )
1385
+ result = _trim_zeros_complex (values , self . decimal , na_rep )
1386
1386
else :
1387
- result = _trim_zeros_float (values , na_rep )
1387
+ result = _trim_zeros_float (values , self . decimal , na_rep )
1388
1388
return np .asarray (result , dtype = "object" )
1389
1389
1390
1390
return values
@@ -1754,19 +1754,21 @@ def just(x):
1754
1754
return result
1755
1755
1756
1756
1757
- def _trim_zeros_complex (str_complexes : np .ndarray , na_rep : str = "NaN" ) -> List [str ]:
1757
+ def _trim_zeros_complex (
1758
+ str_complexes : np .ndarray , decimal : str = "." , na_rep : str = "NaN"
1759
+ ) -> List [str ]:
1758
1760
"""
1759
1761
Separates the real and imaginary parts from the complex number, and
1760
1762
executes the _trim_zeros_float method on each of those.
1761
1763
"""
1762
1764
return [
1763
- "" .join (_trim_zeros_float (re .split (r"([j+-])" , x ), na_rep ))
1765
+ "" .join (_trim_zeros_float (re .split (r"([j+-])" , x ), decimal , na_rep ))
1764
1766
for x in str_complexes
1765
1767
]
1766
1768
1767
1769
1768
1770
def _trim_zeros_float (
1769
- str_floats : Union [np .ndarray , List [str ]], na_rep : str = "NaN"
1771
+ str_floats : Union [np .ndarray , List [str ]], decimal : str = "." , na_rep : str = "NaN"
1770
1772
) -> List [str ]:
1771
1773
"""
1772
1774
Trims zeros, leaving just one before the decimal points if need be.
@@ -1778,8 +1780,11 @@ def _is_number(x):
1778
1780
1779
1781
def _cond (values ):
1780
1782
finite = [x for x in values if _is_number (x )]
1783
+ has_decimal = [decimal in x for x in finite ]
1784
+
1781
1785
return (
1782
1786
len (finite ) > 0
1787
+ and all (has_decimal )
1783
1788
and all (x .endswith ("0" ) for x in finite )
1784
1789
and not (any (("e" in x ) or ("E" in x ) for x in finite ))
1785
1790
)
@@ -1788,7 +1793,7 @@ def _cond(values):
1788
1793
trimmed = [x [:- 1 ] if _is_number (x ) else x for x in trimmed ]
1789
1794
1790
1795
# leave one 0 after the decimal points if need be.
1791
- return [x + "0" if x .endswith ("." ) and _is_number (x ) else x for x in trimmed ]
1796
+ return [x + "0" if x .endswith (decimal ) and _is_number (x ) else x for x in trimmed ]
1792
1797
1793
1798
1794
1799
def _has_names (index : Index ) -> bool :
0 commit comments