Q:

Write a NumPy program to rearrange the dimensions of a given array

0

Write a NumPy program to rearrange the dimensions of a given array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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]]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now