Write a NumPy program to rearrange the dimensions of a given array.
import numpy as np x = np.arange(24).reshape((6,4)) print("Original arrays:") print(x) new_array = np.transpose(x) print("After reverse the dimensions:") print(new_array)
Sample Output:
Original arrays: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15] [16 17 18 19] [20 21 22 23]] After reverse the dimensions: [[ 0 4 8 12 16 20] [ 1 5 9 13 17 21] [ 2 6 10 14 18 22] [ 3 7 11 15 19 23]]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer