Print full Numpy array without truncation
Last Updated :
29 Apr, 2025
The goal here is to print the full NumPy array without truncation, meaning all elements should be displayed regardless of the array’s size. By default, NumPy truncates large arrays to avoid overwhelming the display. However, there are different methods to configure the printing options so that the entire array is shown. Let’s explore a few approaches to accomplish this.
Using np.set_printoptions
np.set_printoptions function control how NumPy arrays are printed. By setting the threshold parameter to sys.maxsize, you are telling NumPy to print the entire array without truncating it, regardless of its size.
[GFGTABS]
Python
import numpy as np
import sys
a = np.arange(101)
np.set_printoptions(threshold=sys.maxsize)
print(a)
[/GFGTABS]
Output

Using np.set_printoptions
Explanation: np.set_printoptions(threshold=sys.maxsize) ensures the entire array is printed without truncation, regardless of size.
Using np.array2string with separator and max_line_width
np.array2string converts a NumPy array into a string representation, with customizable formatting options. The separator option defines how elements in the array are separated and max_line_width determines how wide each line of the output can be before it breaks into a new line.
[GFGTABS]
Python
import numpy as np
import sys
a = np.arange(101)
print(np.array2string(a, separator=',', max_line_width=sys.maxsize))
[/GFGTABS]
Output

Using np.array2string
Explanation: This code converts the array a into a string with elements separated by commas and ensures the entire array is printed on a single line without line breaks.
Using list()
This method converts a NumPy array into a Python list, which can be printed more easily or processed using standard Python list operations. NumPy arrays are more efficient for numerical operations, but sometimes you might need the flexibility of lists.
[GFGTABS]
Python
import numpy as np
a = np.arange(101)
print(list(a))
[/GFGTABS]
Output
[np.int64(0), np.int64(1), np.int64(2), np.int64(3), np.int64(4), np.int64(5), np.int64(6), np.int64(7), np.int64(8), np.int64(9), np.int64(10), np.int64(11), np.int64(12), np.int64(13), np.int64(14),...
Explanation: list(a) converts the NumPy array a into a Python list and prints it.
Using np.printoptions
np.printoptions context manager allows you to temporarily modify printing options within a specific code block. By using np.printoptions with threshold=sys.maxsize, you can print large arrays fully without truncation during the block execution.
[GFGTABS]
Python
import numpy as np
import sys
a = np.arange(101)
with np.printoptions(threshold=sys.maxsize):
print(a)
[/GFGTABS]
Output

Using printoptions
Explanation: This code temporarily changes the print settings to display the entire array without truncation. The print(a) then prints the full array, showing all elements.
Similar Reads
Print a NumPy Array Without Scientific Notation in Python
We have given you a Numpy array. We are going to display the Numpy array without scientific notation and with the given precision. In this article, we are going to explore different methods in Python. Example Input 1: Array = [123.456, 0.123456, 987.123] , Precision = 2Output 1: [123.46 0.12 987.12]
3 min read
Python: Operations on Numpy Arrays
NumPy is a Python package which means 'Numerical Python'. It is the library for logical computing, which contains a powerful n-dimensional array object, gives tools to integrate C, C++ and so on. It is likewise helpful in linear based math, arbitrary number capacity and so on. NumPy exhibits can lik
3 min read
numpy.array_str() in Python
numpy.array_str()function is used to represent the data of an array as a string. The data in the array is returned as a single string. This function is similar to array_repr, the difference being that array_repr also returns information on the kind of array and its data type. Syntax : numpy.array_st
2 min read
Create a Numpy array filled with all zeros - Python
In this article, we will learn how to create a Numpy array filled with all zeros, given the shape and type of array. We can use Numpy.zeros() method to do this task. Let's understand with the help of an example: [GFGTABS] Python import numpy as np # Create a 1D array of zeros with 5 elements array_1
2 min read
Splitting Arrays in NumPy
NumPy arrays are an essential tool for scientific computing. However, at times, it becomes necessary to manipulate and analyze specific parts of the data. This is where array splitting comes into play, allowing you to break down an array into smaller sub-arrays, making the data more manageable. It i
6 min read
NumPy - Create array filled with all ones
To create an array filled with all ones, given the shape and type of array, we can use numpy.ones() method of NumPy library in Python. [GFGTABS] Python import numpy as np array = np.ones(5) print(array) [/GFGTABS]Output: [1. 1. 1. 1. 1.] 2D Array of OnesWe can also create a 2D array (matrix) filled
2 min read
Python | numpy.array_split() method
With the help of numpy.array_split() method, we can get the splitted array of having different dimensions by using numpy.array_split() method. Syntax : numpy.array_split() Return : Return the splitted array of one dimension. Example #1 : In this example we can see that by using numpy.array_split() m
1 min read
Python | Numpy numpy.ndarray.__sub__()
With the help of Numpy numpy.ndarray.__sub__(), We can subtract a particular value that is provided as a parameter in the ndarray.__sub__() method. Value will be subtracted to each and every element in a numpy array. Syntax: ndarray.__sub__($self, value, /) Return: self-value Example #1 : In this ex
1 min read
Python | Numpy numpy.ndarray.__truediv__()
With the help of Numpy numpy.ndarray.__truediv__(), we can divide a particular value that is provided as a parameter in the ndarray.__truediv__() method. Value will be divided to each and every element in a numpy array. Syntax: ndarray.__truediv__($self, value, /) Return: self/value Example #1 : In
1 min read
Convert Python List to numpy Arrays
NumPy arrays are more efficient than Python lists, especially for numerical operations on large datasets. NumPy provides two methods for converting a list into an array using numpy.array() and numpy.asarray(). In this article, we'll explore these two methods with examples for converting a list into
4 min read