Re: [Tutor] filtering NaN values

2009-06-23 Thread Kent Johnson
On Tue, Jun 23, 2009 at 1:53 AM, Alan Gauld wrote: > Interesting! How is a NaN stored in Python? > ie. How do you get to the point of having one in the first place? Google 'python nan' for lots of interesting discussion... Kent ___ Tutor maillist - Tu

Re: [Tutor] filtering NaN values

2009-06-22 Thread John Fouhy
2009/6/23 Alan Gauld : > Interesting! How is a NaN stored in Python? > ie. How do you get to the point of having one in the first place? Well, you can do this: >>> float('nan') nan (try float('inf') too) -- John. ___ Tutor maillist - Tutor@python.o

Re: [Tutor] filtering NaN values

2009-06-22 Thread Alan Gauld
"Kent Johnson" wrote I have a list with some values being NaN (after division-by-zero). How can I check and remove all the NaN values? In Python 2.6 you can use math.isnan() to check for NaN, so you can filter your list by newList = [ x for x in oldList if not math.isnan(x) ] Interesting!

Re: [Tutor] filtering NaN values

2009-06-22 Thread Kent Johnson
On Mon, Jun 22, 2009 at 4:15 PM, Elisha Rosensweig wrote: > Hi, > > I have a list with some values being NaN (after division-by-zero). How can I > check and remove all the NaN values? In Python 2.6 you can use math.isnan() to check for NaN, so you can filter your list by newList = [ x for x in old

Re: [Tutor] filtering NaN values

2009-06-22 Thread Alan Gauld
"Elisha Rosensweig" wrote I have a list with some values being NaN (after division-by-zero). How can I check and remove all the NaN values? NaN is, so far as I know, a JavaScript only feature. The equivalent thing in Python would be to avoid having those 'values' in your list in the first p

[Tutor] filtering NaN values

2009-06-22 Thread Elisha Rosensweig
Hi, I have a list with some values being NaN (after division-by-zero). How can I check and remove all the NaN values? Thanks Elisha ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor