小编Avt*_*ili的帖子

从 R 数组到 Numpy 数组

可以说,我有一个以下 R 数组

a <- array(1:18, dim = c(3, 3, 2))

r$> a
, , 1

     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

, , 2

     [,1] [,2] [,3]
[1,]   10   13   16
[2,]   11   14   17
[3,]   12   15   18
Run Code Online (Sandbox Code Playgroud)

现在我想在 Python numpy 中拥有相同的数组。我用

a = np.arange(1, 19).reshape((3, 3, 2))

array([[[ 1,  2],
        [ 3,  4],
        [ 5,  6]],

       [[ 7,  8],
        [ 9, 10],
        [11, 12]],

       [[13, 14],
        [15, 16], …
Run Code Online (Sandbox Code Playgroud)

python numpy r

8
推荐指数
1
解决办法
562
查看次数

标签 统计

numpy ×1

python ×1

r ×1