1.6 Number Formatting

pandas also allows you to set how numbers are displayed in the console. This option is not set through the set_options API.

Use the set_eng_float_format function to alter the floating-point formatting of pandas objects to produce a particular format.

For instance:

In [1]: import numpy as np

In [2]: pd.set_eng_float_format(accuracy=3, use_eng_prefix=True)

In [3]: s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])

In [4]: s/1.e3
Out[4]: 
a    469.112u
b   -282.863u
c     -1.509m
d     -1.136m
e      1.212m
dtype: float64

In [5]: s/1.e6
Out[5]: 
a    469.112n
b   -282.863n
c     -1.509u
d     -1.136u
e      1.212u
dtype: float64

To round floats on a case-by-case basis, you can also use round() and round().