NumPy | flipud method
flipud(~) method reverses the ordering of the elements row-wise (vertical flip). Note that this method does not flip bits (i.e. turns 0s into 1s, and 1s into 0s).
This method is equivalent to
np.flip(a, axis=0), where
a is the input array.
The input array.
A NumPy array with the input elements reversed row-wise.
Consider the following 2D array:
a = np.array([[1,2,3],[4,5,6],[7,8,9]])aarray([[1, 2, 3],[4, 5, 6],[7, 8, 9]])
To reverse the ordering of the elements row-wise:
np.flipud(a)array([[7, 8, 9],[4, 5, 6],[1, 2, 3]])
Here, the first row became the last element.