I am trying to do hands on the numpy, i cam across following datatype when used inbuilt method dtype.Following the few results i have got. Can you please explain what it means by u11
a1 = np.array([3,5,'p'])
print(a1.dtype)
o/p = >U11
I am trying to do hands on the numpy, i cam across following datatype when used inbuilt method dtype.Following the few results i have got. Can you please explain what it means by u11
a1 = np.array([3,5,'p'])
print(a1.dtype)
o/p = >U11
Numpy's array objects that are
PyArrayObject
types have aNPY_PRIORITY
attribute that denotes the priority of the type in which should be considered as the array'sdtype
in cases that it contains items with heterogeneous data types. You can access to this priority usingPyArray_GetPriority
API which Returns the__array_priority__
attribute (converted to a double) of obj or def if no attribute of that name exists. In this case Unicode has a more priority than integer type and that's whya1.dtype
returnsU11
.Now, regarding the
U11
or in generalU#
, it consists of two parts. TheU
which denotes a Unicodedtype
and the#
denotes the number of elements it can hold. This may be different in different platforms though.Read more info in greater details about string types and other datatype objects in documentation https://docs.scipy.org/doc/numpy-1.14.0/reference/arrays.dtypes.html#data-type-objects-dtype.