Printing large NumPy arrays without truncation
Start your free 7-days trial now!
Suppose we have a large Numpy array like follows:
np.arange(5000)array([ 0, 1, 2, ..., 4997, 4998, 4999])
As we can see, Numpy truncates large arrays when printing by default.
Using the set_printoptions method
In order to print the array in its entirety, we must configure Numpy like follows:
Now, when we print our large array again, we will see all its numbers:
np.arange(5000)** You'll see all the numbers printed here **
Using the printoptions method
For those who are using NumPy 1.15 or above, you could also use the
printoptions(~) method like follows:
with np.printoptions(threshold=np.inf):print(np.arange(5000))** You'll see all the numbers printed here **