gpt4 book ai didi

python - 转换 numpy 数组中特定列的数据类型

转载 作者:行者123 更新时间:2023-11-28 22:18:34 25 4
gpt4 key购买 nike

<分区>

我想更改 numpy 列的数据类型,但是当我替换原来的 numpy 列时,dtype 不会更改成功。

import numpy as np 

arraylist =[(1526869384.273246, 0, 'a0'),
(1526869385.273246, 1, 'a1'),
(1526869386.273246, 2, 'a2'),
(1526869387.273246, 3, 'a3'),
(1526869388.273246, 4, 'a4'),
(1526869389.273246, 5, 'a5'),
(1526869390.273246, 6, 'a6'),
(1526869391.273246, 7, 'a7'),
(1526869392.273246, 8, 'a8'),
(1526869393.273246, 9, 'a9'),
(1526869384.273246, 0, 'a0'),
(1526869385.273246, 1, 'a1'),
(1526869386.273246, 2, 'a2'),
(1526869387.273246, 3, 'a3'),
(1526869388.273246, 4, 'a4'),
(1526869389.273246, 5, 'a5'),
(1526869390.273246, 6, 'a6'),
(1526869391.273246, 7, 'a7'),
(1526869392.273246, 8, 'a8'),
(1526869393.273246, 9, 'a9')]

array = np.array(arraylist)

array.dtype

dtype('<U32')

array[:,0]=array[:,0].astype("float64")
array[:,0].dtype

>>> dtype('<U32')

事件通过我更改了列的 dtype,但为什么我要替换原始列它仍然是 u32

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com