Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.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中R数组的等价性_Python_R_Multidimensional Array - Fatal编程技术网

Python中R数组的等价性

Python中R数组的等价性,python,r,multidimensional-array,Python,R,Multidimensional Array,我试图在以下方式调用时找到与R的array函数等价的Python array(rep(1, 16), dim = rep(2, 4)) 这导致: , , 1, 1 [,1] [,2] [1,] 1 1 [2,] 1 1 , , 2, 1 [,1] [,2] [1,] 1 1 [2,] 1 1 , , 1, 2 [,1] [,2] [1,] 1 1 [2,] 1 1 , , 2, 2

我试图在以下方式调用时找到与R的
array
函数等价的Python

array(rep(1, 16), dim = rep(2, 4))
这导致:

, , 1, 1

     [,1] [,2]
[1,]    1    1
[2,]    1    1

, , 2, 1

     [,1] [,2]
[1,]    1    1
[2,]    1    1

, , 1, 2

     [,1] [,2]
[1,]    1    1
[2,]    1    1

, , 2, 2

     [,1] [,2]
[1,]    1    1
[2,]    1    1

请检查此项。

请检查numpy。是否保留与您想要的R代码相同的最终尺寸?请检查numpy.full
import numpy as np
np.full((2,2,2, 2), 1)