Reshaping an array in python
You have created an array. you want to reshape the array without altering data, this is method for you. Here, built-in method reshape() is used in Numpy. Let us do this for 1D and 2D array. Reshaping a 1D array into 2D array: This code starts from importing numpy and its object. A single dimensional array is created with elements. The array is reshaped with 3 rows and 2 columns by the use of reshape() function. Original array and reshaped array is printed as output. Python Code: import numpy as np1 # Create a 1D array with elements s_arr = np1.array([11, 22, 33, 44, 55, 66]) # Let us Reshape into 3 rows and 2 columns reshaped_arr = s_arr.reshape(3, 2) print("Original array:", s_arr) print("Reshaped array:\n", reshaped_arr) Output: This is the output for the above program Original array: [11 22 33 44 55 66] Reshaped array:...