将字段添加到结构化的numpy数组 [英] Adding a field to a structured numpy array

查看:74
本文介绍了将字段添加到结构化的numpy数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将字段添加到结构化numpy数组的最干净方法是什么?可以破坏性地完成它,还是必须创建一个新的数组并在现有字段上进行复制?每个字段的内容是否连续存储在内存中,以便可以高效地进行复制?

What is the cleanest way to add a field to a structured numpy array? Can it be done destructively, or is it necessary to create a new array and copy over the existing fields? Are the contents of each field stored contiguously in memory so that such copying can be done efficiently?

推荐答案

如果您使用的是numpy 1.3,则还有numpy.lib.recfunctions.append_fields().

If you're using numpy 1.3, there's also numpy.lib.recfunctions.append_fields().

对于许多安装,您需要import numpy.lib.recfunctions进行访问. import numpy不允许看到numpy.lib.recfunctions

For many installations, you'll need to import numpy.lib.recfunctions to access this. import numpy will not allow one to see the numpy.lib.recfunctions

这篇关于将字段添加到结构化的numpy数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆