PYTHON PROGRAMMING
NaN means Not-a-Number. You need to use it in numerical libraries — but additionally within the Python standard library.

11 hours ago
NaN
stands for Not-a-Number. Thus, a NaN
object represents what this very name conveys — something that isn’t a number. It will possibly be a missing value but additionally a non-numerical value in a numerical variable. As we shouldn’t use a non-numerical value in purely numerical containers, we indicate such a price as not-a-number, NaN
. In other words, we are able to say NaN
represents a missing numerical value.
In this text, we are going to discuss NaN
objects available within the Python standard library.
NaN
values occur continuously in numerical data. In the event you’re keen on details of this value, one can find them, for example, here:
In this text, we is not going to discuss all the small print of NaN
values.¹ As an alternative, we are going to discuss several examples of how you can work with NaN
values in Python.
Each programming language has its own approach to NaN
values. In programming languages focused on computation, NaN
values are fundamental. For instance, in R, you could have NULL
(a counterpart of Python’s None
), NA
(for not available), and NaN
(for not-a-number):
In Python, you could have None
and plenty of objects representing NaN
. It’s value to know that Pandas differentiates between NaN
and NaT
, a price representing missing time. This text will discuss NaN
values in the usual library; NaN
(and NaT
, for that matter) within the mainstream numerical Python frameworks — comparable to NumPy and Pandas — will likely be covered in a future article.
In the event you haven’t worked with numerical data in Python, chances are you’ll not have encountered NaN
in any respect. Nonetheless, NaN
values are ubiquitous in Python programming, so it’s necessary to…