python - get a dict out of an ndarray -


how can recover dict cast numpy ndarray?

i.e. following example, want recover test_dict test_array:

>>> test_dict = { 'one' : 1 } >>> test_array = np.asarray(test_dict) >>> print repr(test_array)  array({'one': 1}, dtype=object) 

these don't work:

>>> test[0] indexerror: 0-d arrays can't indexed  >>> dict(test) typeerror: iteration on 0-d array  >>> test.astype(dict) array({'one': 1}, dtype=object)      # still in array 

"don't move arm that."

but anyway, might use:

>>> test_array array({'one': 1}, dtype=object) >>> test_array.item() {'one': 1} 

or matter

>>> test_array.min() {'one': 1} >>> test_array.max() {'one': 1} >>> test_array.take(0) {'one': 1} >>> test_array.flat[0] {'one': 1} 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -