Issue
I'm trying to print the complete contents of two 1001x1 arrays, but Python only gives me truncated output something like this:
array([[5,45],
[1,23],
......,
[1,24],
[2,31]])
instead of the complete array.
Can anyone give me solution of how to get the complete 1001x1 array?
Solution
I'm going to guess that you tried a simple statement like:
print myarray
... rather than something more explicit like:
for each_item in myarray:
print each_item
... or even:
print ', '.join([str(x) for x in myarray])
The reason you're seeing elided output is, presumably, because numpy
implements a _str_
method in its array
class which tries to give a "reaasonable" default
string representation of the array. They are, presumably, assuming that simple print
statements will be used primarily for debugging, logging, or similar purposes and that reporting of results, or marshaling of results to other processes or storage, is going to be done using more explicit iterations over the data (as I've shown here).
Answered By - Jim Dennis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.