'Numpy array ignores dtype transformation
I am currently trying to transform my numpy object array into a uint32 array:
x_train[0] = np.array([int(i) for i in x_train[0]], dtype='u4').astype(np.uint32)
x_train[0]
(I am using a jupyter notebook)
However, even using two different methods of converting it, I get the following output:
array([586, 436, 824, 206, 783, 764, 24, 573, 196, 276, 312, 216, 803,
517, 184, 76, 821, 700, 270, 588, 880, 337, 298, 858, 138, 725, 97,
63, 253, 454, 219, 338, 780, 701, 782, 485, 488, 619, 300, 357,
572, 493, 731, 559, 28, 391, 474, 742, 178, 252, 11, 888, 413, 310,
22, 868, 766, 67, 716, 578, 152, 346, 98, 293, 431, 4, 699, 319,
371, 863, 516, 743, 333, 497, 439, 263, 506, 718, 537, 582, 749,
463, 195, 713, 453, 111, 760, 854, 773, 873, 330, 446, 320, 633,
660, 89, 55, 663, 711, 93, 394, 717, 890, 370, 541, 269, 249, 642,
807, 450, 600, 210, 513, 149, 622, 702, 682, 326, 264, 231, 311,
292, 790, 810, 341, 328, 171, 551, 140, 340, 194, 610, 378, 367,
836, 738, 53, 797, 487, 457, 125, 435, 461, 7, 690, 246],
dtype=object)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
