From: Lionel R. <lro...@li...> - 2006-09-21 14:17:56
|
Hi all, Is it possible to put masked values into recarrays, I need a array with heterogenous types of datas (datetime objects in the first col, all others are float) but with missing values in some records. For the moment, I don't find any solution for that. I have tried with arrays of dtype=object, but I have problem when I want to compute min, max, ... with an error like: TypeError: function not supported for these types, and can't coerce safely to supported types. thanks -- Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |
From: Travis O. <oli...@ie...> - 2006-09-21 16:43:34
|
Lionel Roubeyrie wrote: > Hi all, > Is it possible to put masked values into recarrays, I need a array with > heterogenous types of datas (datetime objects in the first col, all others > are float) but with missing values in some records. For the moment, I don't > find any solution for that. Either use "nans" or "inf" for missing values or use the masked array object with a complex data-type. You don't need to use a recarray object to get "records". Any array can have "records". Therefore, you can have a masked array of "records" by creating an array with the appropriate data-type. It may also be possible to use a recarray as the "array" for the masked array object becuase the recarray is a sub-class of the array. > I have tried with arrays of dtype=object, but I > have problem when I want to compute min, max, ... with an error like: > TypeError: function not supported for these types, and can't coerce safely to > supported types. > It looks like the max and min functions are not supported for Object arrays. import numpy as N N.maximum.types does not include Object arrays. It probably should. -Travis |
From: Travis O. <oli...@ie...> - 2006-09-21 17:00:55
|
Lionel Roubeyrie wrote: > find any solution for that. I have tried with arrays of dtype=object, but I > have problem when I want to compute min, max, ... with an error like: > TypeError: function not supported for these types, and can't coerce safely to > supported types. > I just added support for min and max methods of object arrays, by adding support for Object arrays to the minimum and maximum functions. -Travis |
From: Lionel R. <lro...@li...> - 2006-09-22 07:35:17
|
Le jeudi 21 septembre 2006 19:01, Travis Oliphant a =E9crit=A0: > Lionel Roubeyrie wrote: > > find any solution for that. I have tried with arrays of dtype=3Dobject,= but > > I have problem when I want to compute min, max, ... with an error like: > > TypeError: function not supported for these types, and can't coerce > > safely to supported types. > > I just added support for min and max methods of object arrays, by adding > support for Object arrays to the minimum and maximum functions. > > -Travis Hello travis, good news, and thanks for your last comment. However, using nans give some= =20 errors with scipy.stats: lionel52>t=3Darray([1,2,nan,4]) lionel53>stats.nanmean(t) =2D------------------------------------------------------------------------= =2D- exceptions.NameError Traceback (most recent= =20 call last) /home/lionel/<ipython console> /usr/lib/python2.4/site-packages/scipy/stats/stats.py in nanmean(x, axis) 258 259 # XXX: this line is quite clearly wrong =2D-> 260 n =3D N-sum(isnan(x),axis) 261 putmask(x,isnan(x),0) 262 return stats.mean(x,axis)/factor NameError: global name 'N' is not defined > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your opinions on IT & business topics through brief surveys -- and earn > cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion =2D-=20 Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |
From: Robert K. <rob...@gm...> - 2006-09-22 08:07:07
|
Lionel Roubeyrie wrote: > good news, and thanks for your last comment. However, using nans give some > errors with scipy.stats: > lionel52>t=array([1,2,nan,4]) > > lionel53>stats.nanmean(t) > --------------------------------------------------------------------------- > exceptions.NameError Traceback (most recent > call last) > > /home/lionel/<ipython console> > > /usr/lib/python2.4/site-packages/scipy/stats/stats.py in nanmean(x, axis) > 258 > 259 # XXX: this line is quite clearly wrong > --> 260 n = N-sum(isnan(x),axis) > 261 putmask(x,isnan(x),0) > 262 return stats.mean(x,axis)/factor > > NameError: global name 'N' is not defined It's a bug in nanmean() as the comment immediately preceding it mentions. I don't know who put it in, but I noticed it and couldn't figure out what it intended to do (or didn't have to time to try). <Looks at svn blame and svn log> Ah, it's Travis's fault. So he can fix it. :-) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Robert K. <rob...@gm...> - 2006-09-22 19:54:44
|
Robert Kern wrote: > <Looks at svn blame and svn log> Ah, it's Travis's fault. So he can fix it. :-) And lo, it was fixed. Amen. http://projects.scipy.org/scipy/scipy/changeset/2217 -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |