Python Numpy rollaxis()














































Python Numpy rollaxis()



Description
NumPy generally stands for Numerical Python and it is a general purpose array processing package.it always provides a high performance multidimensional array object.Numpy is usually for creating array of n dimensions.

Method Name :numpy.rollaxis(a, axis, start=0)
Description : The function rollaxis() is used to roll the specified axis backward as it lies in a specified position. This function continues to be supported for backward compatibility, but you should prefer moveaxis. 

In this article, i will tell you about the parameter and its description
Parameter Name: a
Description :ndarray
It represents an input array.

Parameter Name: axis
Description :int
The axis to roll backwards. The positions of the other axes do not change relative to one another.

Parameter Name: start
Description :int,optional
When the start <= axis is showing then the axis is rolled back until it lies in this position. When start > axis is showing the axis is rolled until it lies before this position. The axis is rolled until it lies before this position. The default, 0, results in a "complete" roll.

Return : This function returns a view of parameter %u2018a%u2019. For earlier versions, a view of a is returned only if the order of the axes is changedand if not happen then the input array is returned.

The first step would be to give syntax
command:
numpy.rollaxis(a, axis, start=0)

Example :
Code :
import numpy as np
arr = np.arange(
27).reshape(3,3,3)
print ('The original array:')
print (arr)

# to roll from axis-2 to axis-0
print ('Applying rollaxis() function:')
print (np.rollaxis(arr,2) )

# to roll from axis 0 to 1 (along width to height)
print(
'Applying rollaxis() function:' )
print (np.rollaxis(arr,2,1))

Output


Comments