numpy.rollaxis() function | Python Last Updated : 22 Apr, 2020 Comments Improve Suggest changes Like Article Like Report numpy.rollaxis() function roll the specified axis backwards, until it lies in a given position. Syntax : numpy.rollaxis(arr, axis, start=0) Parameters : arr : [ndarray] Input array. axis : [int] The axis to roll backwards. The positions of the other axes do not change relative to one another. start : [int, optional] The axis is rolled until it lies before this position. The default, 0, results in a “complete” roll. Return : [ndarray] In earlier NumPy versions, arr is returned only if the order of the axes is changed, otherwise the input array is returned. For NumPy >= 1.10.0, a view of arr is always returned. Code #1 : Python3 # 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) Output : (1, 4, 2, 3) Code #2 : Python3 # 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) Output : (3, 1, 2, 4) Comment More infoAdvertise with us Next Article numpy.rollaxis() function | Python S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy Python numpy-arrayManipulation python Practice Tags : Machine Learningpython Similar Reads numpy.swapaxes() function - Python numpy.swapaxes() function allow us to interchange two axes of a multi-dimensional NumPy array. It focuses on swapping only two specified axes while leaving the rest unchanged. It is used to rearrange the structure of an array without altering its actual data. The syntax of numpy.swapaxes() is:numpy. 2 min read numpy.roll() in Python The numpy.roll() function rolls array elements along the specified axis. Basically what happens is that elements of the input array are being shifted. If an element is being rolled first to the last position, it is rolled back to the first position. Syntax : numpy.roll(array, shift, axis = None) Par 2 min read Numpy recarray.swapaxes() function | Python In numpy, arrays may have a data-types containing fields, analogous to columns in a spreadsheet. An example is [(a, int), (b, float)], where each entry in the array is a pair of (int, float). Normally, these attributes are accessed using dictionary lookups such as arr['a'] and arr['b']. Record array 3 min read Numpy recarray.cumsum() function | Python In numpy, arrays may have a data-types containing fields, analogous to columns in a spreadsheet. An example is [(a, int), (b, float)], where each entry in the array is a pair of (int, float). Normally, these attributes are accessed using dictionary lookups such as arr['a'] and arr['b']. Record array 2 min read Numpy recarray.cumprod() function | Python In numpy, arrays may have a data-types containing fields, analogous to columns in a spreadsheet. An example is [(a, int), (b, float)], where each entry in the array is a pair of (int, float). Normally, these attributes are accessed using dictionary lookups such as arr['a'] and arr['b']. Record array 2 min read Like