belongs to collection: Python NumPy Exercises
sampleArray = numpy.array([[34,43,73],[82,22,12],[53,94,66]])
Expected Output:
Printing Original array [[34 43 73] [82 22 12] [53 94 66]] Sorting Original array by second row [[73 43 34] [12 22 82] [66 94 53]] Sorting Original array by second column [[82 22 12] [34 43 73] [53 94 66]]
Solution:
import numpy print("Printing Original array") sampleArray = numpy.array([[34,43,73],[82,22,12],[53,94,66]]) print (sampleArray) sortArrayByRow = sampleArray[:,sampleArray[1,:].argsort()] print("Sorting Original array by secoond row") print(sortArrayByRow) print("Sorting Original array by secoond column") sortArrayByColumn = sampleArray[sampleArray[:,1].argsort()] print(sortArrayByColumn)
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.
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer