How do I print the full NumPy array, without truncation?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
NumPy truncates large arrays when printing them so terminal output stays manageable. If you want to see the entire array, you need to change NumPy’s print options or render the array through a function that does not summarize it. The right approach depends on whether you want a one-off full print or a process-wide change.
Use np.set_printoptions for Global Behavior
The most direct solution is to set the print threshold high enough that NumPy stops abbreviating the array:
Setting threshold=np.inf tells NumPy not to truncate based on element count.
This affects later array printing in the same process, so it is useful when you are debugging interactively and want full output repeatedly.
Use np.printoptions for a Temporary Scope
If you only want the change for one block of code, use the context manager form:
This is usually the cleaner option in scripts or notebooks because it avoids leaving global print settings changed for the rest of the session.
Control Line Wrapping Too
Sometimes the array is not truncated by threshold, but the output is still hard to read because of line wrapping. You can adjust linewidth as well:
That does not change whether elements are omitted. It only changes how wide NumPy lets each printed line become before wrapping.
Use array2string for Explicit String Rendering
If you want the full array as a string, np.array2string is useful:
This is handy when you want to write the array to a log file, GUI text box, or another custom output destination instead of printing it directly.
Large Arrays Can Still Be Unpleasant to Read
Seeing the full array is not always the same as getting useful information from it. For very large arrays, printing the whole thing can flood the terminal or notebook output and make debugging harder.
In those cases, consider alternatives such as:
- printing the shape
- printing selected slices
- using
arr.min(),arr.max(), or summary statistics - saving to a file with
np.savetxt
For example:
That often gives a more useful signal than dumping millions of values to the console.
Resetting Print Options
If you changed global settings with np.set_printoptions, you can reset them later:
In practice, though, using np.printoptions for local scope is often easier than manually restoring global defaults.
Common Pitfalls
One common mistake is thinking the array itself is truncated. NumPy usually truncates only the string representation, not the underlying data.
Another mistake is setting global print options in a notebook and then forgetting about them. Later cells may produce huge unreadable outputs because the threshold stays at infinity.
Developers also sometimes change linewidth and expect hidden elements to reappear. Line width affects wrapping, not truncation by element count.
Finally, printing a huge full array can be technically correct and still be the wrong debugging tool. For very large arrays, slices and summaries are often more effective.
Summary
- Use
np.set_printoptions(threshold=np.inf)to disable truncation globally. - Use
np.printoptions(threshold=np.inf)when you want the change only temporarily. - Adjust
linewidthif the output wraps too aggressively. - '
np.array2stringis useful when you need the full array as text.' - Full output is sometimes less useful than slices or summary statistics for very large arrays.
Related reading
- How do I read a large csv file with pandas?
- How do I read CSV data into a record array in NumPy?
- How do I remove NaN values from a NumPy array?
- How do I replace NA values with zeros in an R dataframe?
- How do I print the key-value pairs of a dictionary in python
- How do I remove duplicates from a list, while preserving order?
- How do I print to console in pytest?
- How do I print to stderr in Python?

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.