Convert nd array to key, value dictionary
arrays, numpy, python
Solution
Sure: you can use `np.ndenumerate` to accomplish this:
{ index: v for index, v in np.ndenumerate(A) }
Or simply, as DSM pointed out:
dict(np.ndenumerate(A))
Problem
Is there a function in python to convert an nd-array into a dictionary where key is a tuple of index and value is the matrix value at that index? For example: ``` A = np.random.random([3,4,5]) ``` Result: ``` {(i,j,k): A[i,j,k]} ```