The suggested answers aren't working for me. What am I doing wrong?
Asked
Active
Viewed 148 times
1 Answers
2
Display options pertain to display of pandas objects. values
returns a numpy array which is formatted independently from pandas. You can use np.set_printoptions
here:
s = pd.Series([1.2345678])
print(s)
#0 1.234568
pd.options.display.float_format = '{:.2f}'.format
print(s)
#0 1.23
print(s.values)
#[1.2345678]
pd.np.set_printoptions(2)
print(s.values)
#[1.23]
To suppress scientific notation you can specify a formatter:
s = pd.Series([1.2345678e+14])
pd.np.set_printoptions(formatter={'float': lambda x: '{:.3f}'.format(x)})
print(s.values)
#[123456780000000.000]

Stef
- 28,728
- 2
- 24
- 52