Sep-17-2018, 01:32 PM
(Sep-17-2018, 01:09 PM)volcano63 Wrote: Numpy arrays are intended to be used as objects - looping is wasteful and inefficient. This is how you can compare by rows and by columns
Output:In [89]: table = numpy.array(range(1, 10)).reshape(3, 3) In [90]: table Out[90]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) In [91]: compare_to = numpy.array([2, 5, 6]) In [92]: compare_to Out[92]: array([2, 5, 6]) In [93]: # Compare by columns In [94]: table < compare_to Out[94]: array([[ True, True, True], [False, False, False], [False, False, False]]) In [95]: # Compare by rows In [96]: table < compare_to.reshape(3, 1) Out[96]: array([[ True, False, False], [ True, False, False], [False, False, False]])numpy
is a complex package - going into it without learning Python is a bad idea, and using it without learning is an exercise in futility
Hello , thank you so much
For an array [[1 2 3 ][ 4 5 6][7 8 9 ]] you used "numpy.array(range(1, 10))" If it was something like [[7 5 3][12 25 36][1 0 9]] how can I transform it ? Thank you