Loading...
Reshape a 1D NumPy array into a 2D array with specified dimensions.
Reshaping is crucial for preparing data for machine learning models. The reshape() method changes array dimensions without changing data.
Write a function reshape_array(arr, new_shape) that:
Return a dictionary with exactly these three keys.
arr = np.arange(6), new_shape = (2, 3)
{'original_shape': [6], 'new_shape': [2, 3], 'array': [[0, 1, 2], [3, 4, 5]]}6 elements reshaped to 2 rows x 3 columns