numpy.rot90() in Python Last Updated : 08 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The numpy.rot90() method performs rotation of an array by 90 degrees in the plane specified by axis(0 or 1). Syntax: numpy.rot90(array, k = 1, axes = (0, 1)) Parameters : array : [array_like]i.e. array having two or more dimensions. k : [optional , int]No. of times we wish to rotate array by 90 degrees. axes : [array_like]Plane, along which we wish to rotate array. Returns : rotated copy of array Python # Python Program illustrating # numpy.rot90() method import numpy as geek array = geek.arange(12).reshape(3, 4) print("Original array : \n", array) # Rotating array 4 times : Returns same original array print("\nArray being rotated 4 times : \n", geek.rot90(array, 4)) # Rotating once print("\nRotated array : \n", geek.rot90(array)) # Rotating twice print("\nRotated array : \n", geek.rot90(array, 2)) Output : Original array : [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] Array being rotated 4 times : [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] Rotated array : [[ 3 7 11] [ 2 6 10] [ 1 5 9] [ 0 4 8]] Rotated array : [[11 10 9 8] [ 7 6 5 4] [ 3 2 1 0]] Note : These codes won’t run on online IDE's. Please run them on your systems to explore the working Comment More infoAdvertise with us Next Article numpy.rot90() in Python M Mohit Gupta_OMG Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads numpy.roll() in Python The numpy.roll() function rolls array elements along the specified axis. Basically what happens is that elements of the input array are being shifted. If an element is being rolled first to the last position, it is rolled back to the first position. Syntax : numpy.roll(array, shift, axis = None) Par 2 min read numpy.repeat() in Python The numpy.repeat() function repeats elements of the array - arr. Syntax : numpy.repeat(arr, repetitions, axis = None) Parameters : array : [array_like]Input array. repetitions : No. of repetitions of each array elements along the given axis. axis : Axis along which we want to repeat values. By def 2 min read numpy.reshape() in Python In Python, numpy.reshape() function is used to give a new shape to an existing NumPy array without changing its data. It is important for manipulating array structures in Python. Let's understand with an example:Pythonimport numpy as np # Creating a 1D NumPy array arr = np.array([1, 2, 3, 4, 5, 6]) 3 min read numpy.right_shift() in Python numpy.right_shift() function is used to Shift the bits of an integer to the right. Because the internal representation of numbers is in binary format, this operation is equivalent to dividing arr1 by 2**arr2. For example, if the number is 20 and we want to 2-bit right shift then after right shift 2- 2 min read numpy.base_repr() in Python numpy.base_repr(number, base=2, padding=0) function is used to return a string representation of a number in the given base system. For example, decimal number 10 is represented as 1010 in binary whereas it is represented as 12 in octal. Syntax : numpy.base_repr(number, base=2, padding=0) Parameters 3 min read numpy.unpackbits() in Python numpy.unpackbits() is another function for doing binary operations in numpy. It is used to unpacks elements of a uint8 array into a binary-valued output array. Syntax : numpy.unpackbits(arr, axis=None) Parameters : arr : [array_like ndarray] An uint8 type array whose elements should be unpacked. axi 2 min read numpy.left_shift() in Python numpy.left_shift() function is used to Shift the bits of an integer to the left. The bits are shifted to the left by appending arr2 0s(zeroes) at the right of arr1. Since the internal representation of numbers is in binary format, this operation is equivalent to multiplying arr1 by 2**arr2. For exam 2 min read numpy.array_repr() in Python numpy.array_repr()function is used to convert an array to a string. Syntax : numpy.array_repr(arr, max_line_width=None, precision=None, suppress_small=None) Parameters : arr : [array_like] Input array. max_line_width : [int, optional] The maximum number of columns the string should span. Newline cha 2 min read numpy.rollaxis() function | Python numpy.rollaxis() function roll the specified axis backwards, until it lies in a given position. Syntax : numpy.rollaxis(arr, axis, start=0) Parameters : arr : [ndarray] Input array. axis : [int] The axis to roll backwards. The positions of the other axes do not change relative to one another. start 1 min read numpy.binary_repr() in Python numpy.binary_repr(number, width=None) function is used to represent binary form of the input number as a string. For negative numbers, if width is not given, a minus sign is added to the front. If width is given, the twoâs complement of the number is returned, with respect to that width. In a twoâs- 3 min read Like