Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print the full NumPy array, without truncation?

When I print a numpy array, I get a truncated representation, but I want the full array.

Is there any way to do this?

Examples:

>>> numpy.arange(10000) array([   0,    1,    2, ..., 9997, 9998, 9999])  >>> numpy.arange(10000).reshape(250,40) array([[   0,    1,    2, ...,   37,   38,   39],        [  40,   41,   42, ...,   77,   78,   79],        [  80,   81,   82, ...,  117,  118,  119],        ...,         [9880, 9881, 9882, ..., 9917, 9918, 9919],        [9920, 9921, 9922, ..., 9957, 9958, 9959],        [9960, 9961, 9962, ..., 9997, 9998, 9999]]) 
like image 878
kame Avatar asked Jan 01 '10 01:01

kame


People also ask

How do I print an entire NumPy array?

We can use the threshold parameter of the numpy. set_printoptions() function to sys. maxsize to print the complete NumPy array.

How do I print a NumPy array without brackets?

To print a NumPy array without enclosing square brackets, the most Pythonic way is to unpack all array values into the print() function and use the sep=', ' argument to separate the array elements with a comma and a space.


1 Answers

Use numpy.set_printoptions:

import sys import numpy numpy.set_printoptions(threshold=sys.maxsize) 
like image 101
Raja Selvaraj Avatar answered Oct 03 '22 07:10

Raja Selvaraj