[Tutor] array and dictionary
Dinesh B Vadhia
dineshbvadhia at hotmail.com
Sun Sep 21 08:06:39 CEST 2008
Hi! Say, I've got a numpy array/matrix of the form:
[[1 6 1 2 3]
[4 5 4 7 0]
[2 0 8 0 2]
[8 2 6 3 0]
[0 7 0 3 5]
[8 0 3 0 6]
[8 0 0 2 2]
[3 1 0 4 0]
[5 0 8 0 0]
[2 1 0 5 6]]
And, I want to create a dictionary of rows (as the keys) mapped to lists of non-zero numbers in that row ie.
dictionary_non-zeros = {
0: [1 6 1 2 3]
1: [4 5 4 7]
2: [2 8 2]
...
9: [2 1 5 6]
}
How do I do this?
Thanks!
Dinesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080920/ba9e8efc/attachment.htm>
More information about the Tutor
mailing list