如何在不截断的情况下打印完整的 NumPy 数组? [英] How to print the full NumPy array, without truncation?

查看:26
本文介绍了如何在不截断的情况下打印完整的 NumPy 数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打印一个 numpy 数组时,我得到了一个截断的表示,但我想要完整的数组.

有没有办法做到这一点?

示例:

<预><代码>>>>numpy.arange(10000)数组([ 0, 1, 2, ..., 9997, 9998, 9999])>>>numpy.arange(10000).reshape(250,40)数组([[ 0, 1, 2, ..., 37, 38, 39],[ 40, 41, 42, ..., 77, 78, 79],[ 80, 81, 82, ..., 117, 118, 119],...,[9880, 9881, 9882, ..., 9917, 9918, 9919],[9920, 9921, 9922, ..., 9957, 9958, 9959],[9960, 9961, 9962, ..., 9997, 9998, 9999]])

解决方案

使用 numpy.set_printoptions:

导入系统导入 numpynumpy.set_printoptions(threshold=sys.maxsize)

When I print a numpy array, I get a truncated representation, but I want the full array.

Is there any way to do this?

Examples:

>>> numpy.arange(10000)
array([   0,    1,    2, ..., 9997, 9998, 9999])

>>> numpy.arange(10000).reshape(250,40)
array([[   0,    1,    2, ...,   37,   38,   39],
       [  40,   41,   42, ...,   77,   78,   79],
       [  80,   81,   82, ...,  117,  118,  119],
       ..., 
       [9880, 9881, 9882, ..., 9917, 9918, 9919],
       [9920, 9921, 9922, ..., 9957, 9958, 9959],
       [9960, 9961, 9962, ..., 9997, 9998, 9999]])

解决方案

Use numpy.set_printoptions:

import sys
import numpy
numpy.set_printoptions(threshold=sys.maxsize)

这篇关于如何在不截断的情况下打印完整的 NumPy 数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆