将数据集转换为Numpy数组的问题

问题描述 投票:0回答:1

我正在训练将数据行转换为Numpy数组。

这是第一行:

['2013-08-14 00:00:00', '232598', '1.3999999761581', '', '1.1572500056095', '12.302269935608', '51.526794433594', '2.2079374790192', '0.60759371519089', '23.152534484863', '']

然后

import numpy as np
float_data = np.zeros((len(lines), len(header) - 1))
for i, line in enumerate(lines):
 values = [ float(x) for x in line.split(',')[1:]]
 float_data[i, :] = values

我得到:ValueError: could not convert string to float:我猜一个字符串,值“”是问题的原因。如何将''替换为0?

python numpy keras
1个回答
0
投票

您可以使用:

© www.soinside.com 2019 - 2024. All rights reserved.