Is there a method somewhere in a Python package that returns the elements and/ or indexes of an element in a 2d grid. E.g. if we have:
[[1, 2, 3, 4],
[5, 6, 7, 8],
[7, 8, 9, 0]]
..and we give the method the index [0,1]
it should return [1, 6, 3]
(if it could return [[0,0], [1,1], [0,2]]
that would be even better) and giving it [1,1]
would return [5, 2, 8, 7]
(or the corresponding indexes- order isn't important).
There is obviously the simple solution to this, however, it's too slow since I want to do this on a large scale for arrays with several thousand elements. Any suggestions? Thanks in advance.