0

pandas==1.2.4 and python==3.7

This doesn't change the formatting on column A:

import numpy as np
import pandas as pd

df = pd.DataFrame(data=np.random.uniform(0, 1, 9).reshape(3, -1), columns=list('ABC'))
df.style.format({"A": '{:.1f}'})
print(df)

This works, however:

df['A'] = df['A'].map('{:.1f}'.format)
print(df)

So does this:

pd.set_option('display.float_format','{:.1f}'.format)
print(df)

Am I using the feature correctly?

GlaceCelery
  • 921
  • 1
  • 13
  • 30

0 Answers0