0
what is "U21" in dtype?
I defined np3 as below: np3=np.array([2,3,4,'list']) and then np3.dtype I get this: dtype('<U21') what's the meaning of U21?
2 Answers
+ 2
All items of a numpy array must be of the same type. numpy tries to cast efficiently them to a single data type. Read here, for instance:
https://stackoverflow.com/questions/65447594/why-does-np-array1-a-consume-unicode-string-of-21-characters
0
Z.r M
It's more efficient if you use the same datatype in numpy.
try
np3 = np.array(["2","3","4","list"])
then np3.dtype is only
<U4