numpy - is there a 2D dictionary in python? -


i create matrix :

    33  12  23  42  11  32  43  22 33  −   1   1   1   0   0   1   1 12  1   −   1   1   0   0   1   1 23  1   1   −   1   1   1   0   0 42  1   1   1   −   1   1   0   0 11  0   0   1   1   −   1   1   1 32  0   0   1   1   1   −   1   1 43  1   1   0   0   1   1   −   1 22  1   1   0   0   1   1   1   − 

i want query horizontal or vertical titles, created matrix by:

a = np.matrix('99 33    12  23  42  11  32  43 22;33    99  1   1   1   0   0   1   1;12    1   99  1   1   0   0   1   1;23    1   1   99  1   1   1   0   0;42    1   1   1   99  1   1   0   0;11    0   0   1   1   99  1   1   1;32    0   0   1   1   1   99  1   1;43    1   1   0   0   1   1   99  1;22    1   1   0   0   1   1   1   99') 

i want have data if query a[23][11] = 1

so there way can create 2d dictionary, a[23][11] = 1?

thanks

you're asking outside of numpy.

a defauldict default_factory dict gives sense of 2d dictionary want:

>>> collections import defaultdict >>> = defaultdict(dict) >>> a[23][11] = 1 >>> a[23] {11: 1} >>> a[23][11] 1 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -