We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Numpy
- Transpose and Flatten
- Discussions
Transpose and Flatten
Transpose and Flatten
Sort by
recency
|
324 Discussions
|
Please Login in order to post a comment
import numpy N, M = list(map(int, input().strip().split())) my_array = numpy.array([input().strip().split()[:M] for _ in range(N)], dtype=int) print(numpy.transpose(my_array)) print(numpy.sort(numpy.transpose(my_array).flatten()))
import numpy import numpy as np
n, m = map(int, input().strip().split()) matrix = np.array([input().strip().split() for _ in range(n)], dtype=int) transpose = np.transpose(matrix) flatten = matrix.flatten() print(transpose) print(flatten)
import numpy n,m = input().split() og=numpy.array([[s for s in map(int,input().split())] for _ in range(int(n))]) print(numpy.transpose(og)) print(og.flatten())
import numpy as np
n,m = input().split() arr = [] for i in range(int(n)): num = list(map(int, input().split())) arr.append(num) myarr = np.array(arr) print(np.transpose(myarr)) print(myarr.flatten())