hello, I was wondering what might be the best way to structure my data within
python. I am sampling data points, and in each there is a time, value, and text
string associated with that sample. so I was thinking I'd make a list of
'measurement objects' and each object would have the attributes: time, value,
and text... but I want to operate on the numerical values to find the average
and stdev... so I'm not sure how to operate on my data if it is inside an
object.
right now I have three arrays, a date array, a value array, and a text array.
so I can operate on each array without trouble. but it'd be cleaner in my code
and easier to deal with if I had a list of these measurement objects.
for example:
# a class for my measurements
class measurement:
def __init__(self):
self.text = ''
self.value=0
self.time=datetime.today()
# I start with an empty list
measurements = []
# as I collect data in my code I append an object to the list
measurements.append(sample)
measurements[-1].value = value
measurements[-1].text = text
measurements[-1].time = time
# now I don't know what to do here. I want the mean of all my data
# but I need a list or array to operate on but instead my data is inside each
object
# I don't really want to make a temporary array, is there a way to operate on
the
# data in all my objects as if it were an array or list?
mean = numpy.mean(????)
is there a way to operate on the data when it is structured like this?
thanks.
Jeff
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos._______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor