python - 长的 NumPy 数组无法完全打印?

标签 python arrays numpy output-formatting

我正在尝试打印两个 1001x1 数组的完整内容,但 Python 只给我截断的输出,如下所示:

array([[5,45],
       [1,23],
       ......,
       [1,24],
       [2,31]])  

而不是完整的数组。

任何人都可以给我如何获得完整的 1001x1 阵列的解决方案吗?

最佳答案

参见 Printing Arrays 部分在 NumPy 教程中:

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)

np.set_printoptions 函数是 NumPy 库的一部分。

关于python - 长的 NumPy 数组无法完全打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4528612/

相关文章:

python - 我的 QPainter 既不画线也不抛出错误,我该如何解决这个问题?

python - 在 Python 中使用 readline() 时,如何从列表中删除换行符或空字符串?

python - 使用 np.random.rand 的 PIL 逊相关失败

Python valueError 使用 hstack() (ValueError : all the input array dimensions except for the concatenation axis must match exactly)

python - 根据行/列条件创建 DataFrame 掩码

python - 当存在重复项时,如何将两个元素列表转换为字典(一个元素将是键,另一个将是值)?

javascript - 过滤嵌套嵌套数组

python - 使用几个数组中最低的下一个元素,并将变量保存在变量中

java二维数组转字符串数组

python - 如何删除所有重复出现或在 Pandas 数据框中获取唯一值?