Skip to content

Instantly share code, notes, and snippets.

@greggyNapalm
Created August 27, 2013 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggyNapalm/6357893 to your computer and use it in GitHub Desktop.
Save greggyNapalm/6357893 to your computer and use it in GitHub Desktop.
import numpy as np
>>> np.__version__
'1.6.1'
>>> errno_distr = # getter function call here
>>> type(errno_distr)
<type 'numpy.ndarray'>
>>> errno_distr
array([[ 0. , 39597. , 99.99242424],
[ 104. , 1. , 0.00252525],
[ 110. , 2. , 0.00505051]])
>>> errno_distr.dtype
dtype('float64')
>>> errno_distr.shape
(3, 3)
>>> errno_distr[:,0]
array([ 0., 104., 110.]) # this is what I what to get in errno_distr['code'] call
>>> errno_distr.dtype = [('code', float),('count', float),('percentage', float)]
>>> errno_distr.shape # why shape changes? I no need that
(1, 3)
>>> errno_distr[:,0]
array([(0.0, 104.0, 110.0)],
dtype=[('code', '<f8'), ('count', '<f8'), ('percentage', '<f8')])
>>> errno_distr['code'] # unexpected result (
array([[ 0. , 39597. , 99.99242424]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment