Size of data type using NumPy

You need an instance of the dtype to get the itemsize, but you shouldn’t need an instance of the ndarray. (As will become clear in a second, nbytes is a property of the array, not the dtype.)

E.g.

print np.dtype(float).itemsize
print np.dtype(np.float32).itemsize
print np.dtype('|S10').itemsize

As far as the difference between itemsize and nbytes, nbytes is just x.itemsize * x.size.

E.g.

In [16]: print np.arange(100).itemsize
8

In [17]: print np.arange(100).nbytes
800

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)