Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

NumPy roll Example

# welcome to softhunt.net
# Python Program illustrating
# numpy.roll() method

import numpy as np

array = np.arange(9).reshape(3, 3)
print("Original array : 
", array)

# Rolling array; Shifting one place
print("
Rolling with 1 shift : 
", np.roll(array, 1))

# Rolling array; Shifting five places
print("
Rolling with 5 shift : 
", np.roll(array, 5))

# Rolling array; Shifting five places with 0th axis
print("
Rolling with 2 shift with 0 axis : 
", np.roll(array, 2, axis = 0))
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #NumPy #roll #Example
ADD COMMENT
Topic
Name
8+5 =