0

I am using Jupterlab 0.18.1. and try to learn pandas. Created a dataframe and applied some ufuncs from numpy. Then applied numpy.set_printoptions, precision = 4 and suppress =Ture, but even after that, I am not getting the desired result in printing.

rng = np.random.RandomState(42)
df = pd.DataFrame(rng.randint(0, 10, (3, 4)),
              columns=['A', 'B', 'C', 'D'])
np.set_printoptions(precision=4,suppress=True)
data = np.sin(df * np.pi / 4)
print(data)

output

     A             B         C             D
0 -1.000000  7.071068e-01  1.000000 -1.000000e+00
1 -0.707107  1.224647e-16  0.707107 -7.071068e-01
2 -0.707107  1.000000e+00 -0.707107  1.224647e-16

What else I missed? Please help

Chanda Korat
  • 2,453
  • 2
  • 19
  • 23

1 Answers1

1

There are also printing options for pandas.

pd.set_option('precision', 4)
languitar
  • 6,554
  • 2
  • 37
  • 62