steve+comp.lang.python at pearwood.info
Thu Apr 28 20:59:45 CEST 2011
On Thu, 28 Apr 2011 10:01:49 -0700, Chris Rebert wrote:
> > 2. What are the use cases for NaN? Looks like it gets used a lot as a
> > numeric (float?) object with non-value.
> And it's
> used to represent missing numeric data values, sort of like a
> numerical None/Null: "How much does the truck weigh? NaN (i.e. No
> idea; we haven't put it on the scale yet)."
While it is common, it is also an abuse of NANs to use it to represent
missing values. In Python, that's (probably) best done with None. The
statistics language R has a specific value NA to use for missing,
distinct from NANs.
Still, it could be worse... I've seen a programs use 9999 to represent
missing values, on the basis that nobody could ever have more than (say)
5000 invoices in the database...
(I wish I was exaggerating.)
More information about the Python-list