in

NaN Values within the Python Customary Library | by Marcin Kozak | Oct, 2023

NaN-Values-in-the-Python-Standard-Library-by-Marcin.jpeg

[ad_1]

PYTHON PROGRAMMING

NaN means Not-a-Quantity. You should utilize it in numerical libraries — but in addition within the Python normal library.

Marcin KozakTowards Data SciencePicture by cyrus gomez on Unsplash

NaN stands for Not-a-Quantity. Thus, a NaN object represents what this very title conveys — one thing that isn’t a quantity. It may be a lacking worth but in addition a non-numerical worth in a numerical variable. As we shouldn’t use a non-numerical worth in purely numerical containers, we point out such a price as not-a-number, NaN. In different phrases, we will say NaN represents a lacking numerical worth.

On this article, we’ll talk about NaN objects accessible within the Python normal library.

NaN values happen regularly in numerical information. When you’re all in favour of particulars of this worth, you can find them, as an example, right here:

On this article, we is not going to talk about all the main points of NaN values.¹ As an alternative, we’ll talk about a number of examples of how one can work with NaN values in Python.

Every programming language has its personal method to NaN values. In programming languages targeted on computation, NaN values are basic. For instance, in R, you’ve NULL (a counterpart of Python’s None), NA (for not accessible), and NaN (for not-a-number):

R has NA for missing value and NaN for not-a-number, and NULL for None.Screenshot from an R session. Picture by creator.

In Python, you’ve None and plenty of objects representing NaN. It’s price to know that Pandas differentiates between NaN and NaT, a price representing lacking time. This text will talk about 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 coated in a future article.

When you haven’t labored with numerical information in Python, it’s possible you’ll not have encountered NaN in any respect. Nonetheless, NaN values are ubiquitous in Python programming, so it’s essential to…

[ad_2]

Supply hyperlink

What do you think?

Written by TechWithTrends

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

Instagram-CEO-says-iPad-app-still-not-a-priority.jpg

Instagram CEO says iPad app nonetheless not a precedence

Ideological-Purity-Has-No-Place-In-Politics.jpg

Ideological Purity Has No Place In Politics