开发者社区> 问答> 正文

Python-无法将float转换为numpy数组

我正在将float转换为numpy数组,但是无法这样做。我得到的错误是

IndexError:仅整数,slice(:),省略号(...),numpy.newaxis(None)和整数或布尔数组为有效索引

我曾尝试将整个数组(TD)转换为浮点数,但是无法这样做 full_x[start_evt_ind:(start_evt_ind + num_events)] = x

full_y[start_evt_ind:(start_evt_ind + num_events)] = y

full_p[start_evt_ind:(start_evt_ind + num_events)] = evt_subtype

full_ts[start_evt_ind:(start_evt_ind + num_events)] = ts

full_f[start_evt_ind:(start_evt_ind + num_events)] = evt_type

start_evt_ind = start_evt_ind + num_events

TD=np.rec.array(None, dtype=[('x', np.float32), ('y', np.float32), ('p', np.bool_), ('ts', np.float32)], shape = (len(full_x[TD_indices])))

展开
收起
被纵养的懒猫 2019-09-25 16:01:31 807 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载