wesm/pandas — Issue #581: New numeric display adds sometimes unwanted trailing zeros
Author: lodagro
Created: 2012-01-06 15:19:23+00:00
State: open

New numeric display adds sometimes unwanted trailing zeros.

One should also be careful when adding trailing zeros. In the example below, pi is represented up to the default precision of three and trailing zeros are added. I'm not in favor of this. To write pi=3.142 is ok, pi=3.1420000 is not ok.

```python
In [3]: df = pandas.DataFrame({'A': [np.pi, np.pi*100000]})

In [4]: df
Out[4]:
A
0 3.1420000
1 3.142e+05

In [5]: pandas.set_printoptions(precision=5)
In [6]: df
Out[6]:
A
0 3.14160000
1 3.1416e+05
```

In this example -1 and 1 become -10000 and 10000.

```python
In [5]: df = pandas.DataFrame({'A': [-1, 1, -1e-1, 1e-1, -1e-2, 1e-2, -1e-3, 1e-3]})

In [6]: df
Out[6]:
A
0 -10000
1 10000
2 -0.100
3 0.100
4 -0.010
5 0.010
6 -0.001
7 0.001

In [7]: df['A'][0]
Out[7]: -1.0
```

When enabling the engineering float formatter, things get messy.

```python
In [8]: pandas.set_eng_float_format(use_eng_prefix=True)

In [9]: df
Out[9]:
A
0 -1.000000
1 1.0000000
2 -100.000m
3 100.000m0
4 -10.000m0
5 10.000m00
6 -1.000m00
7 1.000m000

In [10]: pandas.set_eng_float_format(precision=1, use_eng_prefix=True)

In [11]: df
Out[11]:
A
0 -1.0000
1 1.00000
2 -100.0m
3 100.0m0
4 -10.0m0
5 10.0m00
6 -1.0m00
7 1.0m000
```

Maybe easier to replace added trailing zeros with white space?