I am trying to find the column with maximum column-sum of a 2D matrix in numpy. For example:
Let A = [[1, 2, 3], [0, 1, 4], [0, 0, 1]]
The sums of each column is [1, 3, 8]. Therefore, 3rd column has the maximum column-sum.
While trying numpy.argmax and numpy.sort functions to accomplish this task, I was expecting argmax to be faster than sort ideally but they resulted in same running time.
a = np.random.rand(7000, 8000)
start_time = time.time()
for i in range(1000):
np.sort(np.sum(a, axis = 0))
print(time.time() - start_time)
Above code runs in 33.29 seconds while the below code also runs in 34.33 seconds.
a = np.random.rand(7000, 8000)
start_time = time.time()
for i in range(1000):
np.argmax(np.sum(a, axis=0))
print(time.time() - start_time)
Could you please let me know the potential reasons behind this? Is it something related to how I am solving the problem?