Approximation of numbers in a matrix

0

I have the following matrix:
[[-397. -259. -51. -227. -116. -227.]
 [351. 237. 58. 204. 117. 204.]
 [-140. -98. -25. -83. -fifty. -83.]]

and I'm trying to leave this matrix, all in module 29 as follows: lista1 = []
for x in matrizf:
    x = x% 29
    lista1.append (x)
c = np.array (list1) .reshape (3, -1)
print ("-MATRIZ FINAL-")
print (c)

but I print it like this:
[[9.00000000e + 00 2.00000000e + 00 7.00000000e + 00 5.00000000e + 00   5.54223334e-13 5.00000000e + 00]
 [3.00000000e + 00 5.00000000e + 00 2.90000000e + 01 1.00000000e + 00   1.00000000e + 00 1.00000000e + 00]
 [5.00000000e + 00 1.80000000e + 01 4.00000000e + 00 4.00000000e + 00   8.00000000e + 00 4.00000000e + 00]]

As they realize, I printed all the matirz with several decimals, so I need to approximate those numbers and how some numbers will tell me how the 0 prints it to me in the following way: 5.54223334e-13.
in the end I just need the matrix to stay like this:
[[9 2 7 5 0 5]
 [3 5 0 1 1 1]
 [5 18 4 4 8 4]]

    
asked by AXL 03.11.2018 в 04:31
source

1 answer

0

You can use np.around to remove the decimals from the array, something like this:

lista1 = np.around(lista1);

Good luck!

    
answered by 03.11.2018 в 04:51