📜  numpy.moveaxis()函数| Python

📅  最后修改于: 2022-05-13 01:54:34.153000             🧑  作者: Mango

numpy.moveaxis()函数| Python

numpy.moveaxis()函数将数组的轴移动到新位置。其他轴保持原来的顺序。

代码#1:

# Python program explaining
# numpy.moveaxis() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.zeros((1, 2, 3, 4))
  
gfg = geek.moveaxis(arr, 0, -1).shape
  
print (gfg)

输出 :

(2, 3, 4, 1)


代码#2:

# Python program explaining
# numpy.moveaxis() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.zeros((1, 2, 3, 4))
  
gfg = geek.moveaxis(arr, -1, 0).shape
  
print (gfg)

输出 :

(4, 1, 2, 3)