numpy.rot90() in Python Last Updated : 08 Mar, 2024 Summarize Comments Improve Suggest changes Share 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 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 Like