Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中包装numpy数组_Python_Arrays_Numpy - Fatal编程技术网

在python中包装numpy数组

在python中包装numpy数组,python,arrays,numpy,Python,Arrays,Numpy,我在python中使用numpy数组,并试图更好地可视化它们,以查看我正在使用的内容。当数组换行到下一行时,是否有方法进行更改? 例如,在terminal窗口中,我有足够的列在一行上显示0-49,但当我转换为数组数据类型时,它会自动换行 >>> tmp.shape (2, 50) >>> print tmp [[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2

我在python中使用numpy数组,并试图更好地可视化它们,以查看我正在使用的内容。当数组换行到下一行时,是否有方法进行更改? 例如,在terminal窗口中,我有足够的列在一行上显示0-49,但当我转换为数组数据类型时,它会自动换行

>>> tmp.shape
(2, 50)
>>> print tmp
[[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  48 49]
 [50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
  74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
  98 99]]
>>> 

默认情况下,Numpy在显示数组时仅打印75个字符。您可以使用numpy.set_printpoptions()更改此设置

例如,我将终端设置为显示132x43,并得到以下结果:

>>> import numpy as np
>>> np.set_printoptions(linewidth=132)
>>> a = np.arange(100).reshape(2,50)
>>> a
array([[ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
    31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49],
   [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
    81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]])

为什么18岁和19岁之间差距很大?