打印 numpy 数组的所有列和行

问题描述:

如截图所示,二维 numpy 数组被截断用于打印目的.我想显示所有元素.是否有启用该行为的选项设置?

As shown in the screenshot a 2D numpy array is truncated for printing purposes. I would like to have all elements displayed. Is there an option setting to enable that behavior?

参见 有关打印选项的文档.具体:

阈值:整数,可选

触发汇总而不是完整repr的数组元素总数(默认为1000).

Total number of array elements which trigger summarization rather than full repr (default 1000).

因此将 threshold 设置为 np.inf 意味着它永远不会被汇总.

So setting threshold to np.inf means it is never summarized.

np.set_printoptions(threshold=np.inf)