- NumPy Tutorial
- NumPy - Home
- NumPy - Introduction
- NumPy - Environment
- NumPy - Ndarray Object
- NumPy - Data Types
- NumPy - Array Attributes
- NumPy - Array Creation Routines
- NumPy - Array from Existing Data
- Array From Numerical Ranges
- NumPy - Indexing & Slicing
- NumPy - Advanced Indexing
- NumPy - Broadcasting
- NumPy - Iterating Over Array
- NumPy - Array Manipulation
- NumPy - Binary Operators
- NumPy - String Functions
- NumPy - Mathematical Functions
- NumPy - Arithmetic Operations
- NumPy - Statistical Functions
- Sort, Search & Counting Functions
- NumPy - Byte Swapping
- NumPy - Copies & Views
- NumPy - Matrix Library
- NumPy - Linear Algebra
- NumPy - Matplotlib
- NumPy - Histogram Using Matplotlib
- NumPy - I/O with NumPy
- NumPy Useful Resources
- NumPy Compiler
- NumPy - Quick Guide
- NumPy - Useful Resources
- NumPy - Discussion
numpy.rollaxis
This function rolls the specified axis backwards, until it lies in a specified position. The function takes three parameters.
numpy.rollaxis(arr, axis, start)
Where,
Sr.No. | Parameter & Description |
---|---|
1 | arr Input array |
2 | axis Axis to roll backwards. The position of the other axes do not change relative to one another |
3 | start Zero by default leading to the complete roll. Rolls until it reaches the specified position |
Example
# It creates 3 dimensional ndarray import numpy as np a = np.arange(8).reshape(2,2,2) print 'The original array:' print a print '\n' # to roll axis-2 to axis-0 (along width to along depth) print 'After applying rollaxis function:' print np.rollaxis(a,2) # to roll axis 0 to 1 (along width to height) print '\n' print 'After applying rollaxis function:' print np.rollaxis(a,2,1)
Its output is as follows −
The original array: [[[0 1] [2 3]] [[4 5] [6 7]]] After applying rollaxis function: [[[0 2] [4 6]] [[1 3] [5 7]]] After applying rollaxis function: [[[0 2] [1 3]] [[4 6] [5 7]]]
numpy_array_manipulation.htm
Advertisements