📜  numpy.rollaxis()函数| Python

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

numpy.rollaxis()函数| Python

numpy.rollaxis()函数向后滚动指定的轴,直到它位于给定位置。

代码#1:

# Python program explaining
# numpy.rollaxis() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.ones((1, 2, 3, 4))
  
gfg = geek.rollaxis(arr, 3, 1).shape
  
print (gfg)

输出 :

(1, 4, 2, 3)


代码#2:

# Python program explaining
# numpy.rollaxis() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.ones((1, 2, 3, 4))
  
gfg = geek.rollaxis(arr, 2).shape
  
print (gfg)

输出 :

(3, 1, 2, 4)