¡@

Home 

python Programming Glossary: np.dtype

Reading a direct access fortran unformatted file in Python

http://stackoverflow.com/questions/10475839/reading-a-direct-access-fortran-unformatted-file-in-python

count nx ny field np.reshape field nx ny return field a np.dtype 'd' a readslice 'test' a 100 100 2 im plt.imshow a plt.show..

Reading and storing arbitrary byte length integers from a file

http://stackoverflow.com/questions/11508010/reading-and-storing-arbitrary-byte-length-integers-from-a-file

size integer buf 000000111111222222 a np.ndarray len buf np.dtype ' i1' buf e np.zeros len buf 6 np.dtype ' i8' for i in range.. np.ndarray len buf np.dtype ' i1' buf e np.zeros len buf 6 np.dtype ' i8' for i in range 3 e.view dtype ' i2' i 1 4 a.view dtype..

convert binary string to numpy array

http://stackoverflow.com/questions/11760095/convert-binary-string-to-numpy-array

x00 x00@ x00 x00@@ x00 x00 x80@' dtype ' f4' # or dtype np.dtype ' f4' or np.float32 on a little endian system which most computers.. x00 x00@ x00 x00@@ x00 x00 x80@' dtype ' f4' # or dtype np.dtype ' f4' or np.float32 on a big endian system array 4.60060299e..

numpy datetime64 in recarray

http://stackoverflow.com/questions/16618499/numpy-datetime64-in-recarray

Python 2.7 Numpy 1.7. Here's a minimal example p_dtype np.dtype names 'trns_id' 'trns_date' 'qty' 'price' 'amount' 'description'..

find and delete from more-dimensional numpy array

http://stackoverflow.com/questions/16839303/find-and-delete-from-more-dimensional-numpy-array

improve this question This is how I would do it dtype np.dtype np.void p_a_colors.shape 1 p_a_colors.dtype.itemsize mask..

Find unique rows in numpy.array

http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array

0 1 1 1 0 0 0 1 1 1 1 1 0 b np.ascontiguousarray a .view np.dtype np.void a.dtype.itemsize a.shape 1 _ idx np.unique b return_index.. a np.random.randint 2 size 10000 6 timeit np.unique a.view np.dtype np.void a.dtype.itemsize a.shape 1 .view a.dtype .reshape 1.. np.random.randint 2 size 10000 100 timeit np.unique a.view np.dtype np.void a.dtype.itemsize a.shape 1 .view a.dtype .reshape 1..

Custom data types in numpy arrays

http://stackoverflow.com/questions/2350072/custom-data-types-in-numpy-arrays

parameterized by 9 floats and an int you could do kerneldt np.dtype 'myintname' np.int32 'myfloats' np.float64 9 arr np.empty dims..

Define dTypes in NumPy using a list?

http://stackoverflow.com/questions/3410147/define-dtypes-in-numpy-using-a-list

The following code might help import numpy as np dt np.dtype 'name1' ' S10' 'name2' ' f8' tuplelist 'n1' 1.2 'n2' 3.4 arr.. arr 'name2' # 1.2 3.4 Your immediate problem was that np.dtype expects the format specifiers to be numpy types such as ' S10'.. not Python types such as str or float . If you type help np.dtype you'll see many examples of how np.dtypes can be specified...

What is the way data is stored in *.npy

http://stackoverflow.com/questions/4090080/what-is-the-way-data-is-stored-in-npy

documentation UPD lets say tha data is something like dt np.dtype 'outer' ' 3 i4' 'outer2' 'inner' ' 10 i4' 'inner2' 'f8' UPD2.. dtype object import numpy as np a 0 0 0 b 0 0 c a b dtype np.dtype 'Name' ' S2' 'objValue' object data np.zeros 3 dtype data 0..

Getting data from ctypes array into numpy

http://stackoverflow.com/questions/4355524/getting-data-from-ctypes-array-into-numpy

ctypes.addressof y.contents array_length np.dtype float .itemsize I found this in an old numpy mailing list thread.. y.contents 8 array_length Note that I substituted 8 for np.dtype float .itemsize . It's always 8 on any platform. A different..

Named dtype array: Difference between a[0]['name'] and a['name'][0]?

http://stackoverflow.com/questions/9470604/named-dtype-array-difference-between-a0name-and-aname0

numpy which may or may not be a bug import numpy as np dt np.dtype 'tuple' int 2 a np.zeros 3 dt type a 'tuple' 0 # ndarray type..