Long NumPy array can't be printed completely?

前端 未结 2 559
既然无缘
既然无缘 2021-01-14 20:08

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         


        
2条回答
  •  执念已碎
    2021-01-14 20:38

    See the section Printing Arrays in the NumPy tutorial:

    If an array is too large to be printed, NumPy automatically skips the central part of the array and only prints the corners:

    >>> print(np.arange(10000))
    [   0    1    2 ..., 9997 9998 9999]
    

    ...

    To disable this behaviour and force NumPy to print the entire array, you can change the printing options using set_printoptions.

    >>> np.set_printoptions(threshold=nan)
    

    The np.set_printoptions function is part of the NumPy library.

提交回复
热议问题