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
Copyright © 2021 Jogjafile Inc.
Numpy's array objects that are
PyArrayObject
types, have aNPY_PRIORITY
attribute that denotes the priority of the types of items for cases where the array contains items with heterogeneous data types. You can access this priority usingPyArray_GetPriority
API that returns the__array_priority__
attribute which according to the the documents:Now, in this case Unicode has a higher priority than integer type and that's why
a1.dtype
returnsU11
.Regarding the
U11
or in generalU#
, you need to note that it consists of two parts; theU
which denotes a Unicodedtype
and the#
shows the number of elements that it can hold --but it can be different in different platforms.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.