0 votes
in Python by
explain numpy.flip() in Python

1 Answer

0 votes
by

numpy.flip() in Python

The numpy.flip() function is used to reverse the order of elements in an array along the given axis where the shape of the array is preserved, but the elements are reordered.

Syntax

numpy.flip(m, axis=None)

Parameter

m : This parameter represents the Input array.

axis : Axis or axes parameter is used to flip over the values. The default axis value is None, flip over all of the axes of the input array

Return

This function returns a view of m with the entries of axis reversed.

Example 1

# Python program explaining
# numpy.flip () function
import numpy as np
inp_arr = np.arange(8).reshape((2,2,2))
print("Input array: \n", inp_arr)
print("Flipped array: \n", np.flip(inp_arr, 0))

Output

Input array :
[[[0 1]
  [2 3]]
[[4 5]
  [6 7]]]
Flipped array :
[[[4, 5]
  [6, 7]]
[[0, 1]
  [2, 3]]]

Related questions

0 votes
asked May 19, 2022 in Python by john ganales
0 votes
asked May 19, 2022 in Python by john ganales
...