1

NumPy: Transpose 2D array

Unsolved
Data Wrangling

Difficulty: 1 | Problem written by peter.washington

Educational Resource: https://cs231n.github.io/python-numpy-tutorial/


Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

Data scientists must be familiar with manipulating NumPy data.

Given a 2D NumPy array of dimensions  N x M, return the reshaped array of dimensions  M x N. Do this is only one line of code.

Sample Input:
<class 'numpy.ndarray'>
arr: [[0 1] [2 3] [4 5]]

Expected Output:
<class 'numpy.ndarray'>
[[0 1 2] [3 4 5]]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Explicabo culpa eveniet dolorum sapiente est veritatis perferendis suscipit, repudiandae adipisci ea incidunt officiis amet, reprehenderit voluptates accusantium tempore suscipit quo vero exercitationem in odit voluptatibus quos, soluta corrupti repellat?

Accusantium earum blanditiis impedit, accusantium tempore officiis corporis officia aut impedit maiores nam minus nesciunt eaque, totam consequatur doloribus sed eos nisi saepe nemo, ratione praesentium explicabo eum perspiciatis iure soluta consectetur, non numquam praesentium architecto.

Atque quis aliquam pariatur ipsam, ratione aperiam exercitationem veniam?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)