Sorry I am not able to answer your question; I am really a new user of numpy also.Hello,
I like to use record arrays to access fields by their name, and because they are esay to use with pytables. But I think it's not very effiicient for what I have to do. Maybe I'm misunderstanding something.
Example :
import numpy as npage = np.random.randint(0, 99, 10e6)weight = np.random.randint(0, 200, 10e6)data = np.rec.fromarrays((age, weight), names='age, weight')# the kind of operations I do is :data.age += data.age + 1# but it's far less efficient than doing :age += 1# because I think the record array stores [(age_0, weight_0) ...(age_n, weight_n)]# and not [age0 ... age_n] then [weight_0 ... weight_n].
So I think I don't use record arrays for the right purpose. I only need something which would make me esasy to manipulate data by accessing fields by their name.
Am I wrong ? Is their something in numpy for my purpose ? Do I have to implement my own class, with something like :
class FieldArray:def __init__(self, array_dict):self.array_list = array_dictdef __getitem__(self, field):return self.array_list[field]def __setitem__(self, field, value):self.array_list[field] = valuemy_arrays = {'age': age, 'weight' : weight}data = FieldArray(my_arrays)
data['age'] += 1
Thank you for the help,
Jean-Baptiste Rudant
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion