[PYTHON] A memorandum about Nan.

Introduction

Please note that this is a memorandum for yourself.

About Nan

Nan is a way of thinking with a small number of fixed points, and indicates that it is an abnormal value. It seems to have the name Missing Value. I wonder if the image is an error that appears when calculating the formula in Excel. Note that it is not None.

The nature of Nan

Nan has an important property. The properties are as follows.

・ Nan is returned as the result of four arithmetic operations including Nan. ・ Nan's comparison operator is always False

Please note that the result is different from the normal calculation.

numpy isnan () function

Isnan () in numpy is a function that determines if there is Nan. Therefore, if you use this in an if statement etc., True will be returned.

nansum () function

Nan will be returned for calculations that include missing values. But I want to calculate a group of numbers including Nan! In that case, use nansum (). By using this, the sum of the values excluding Nan is calculated. It's convenient.

nan_to_num () function

A function for when you want to change Nan to something else. By default, it seems to be changed to 0 and the original ndarray is not changed. Specify the array to be changed with the first argument, specify whether to keep the original array with the second argument, and specify the characters and numbers to replace with the third argument.

Recommended Posts

A memorandum about Nan.
A memorandum about matplotlib
A memorandum about correlation [Python]
A memorandum about Python mock
Memorandum about validation
A memorandum of understanding about django's QueryDict
A note about __call__
A memorandum about the Python tesseract wrapper library
A note about subprocess
A note about mprotect (2)
A memorandum about the warning of the pylint output result
A memorandum of kernel compilation
About python beginner's memorandum function
A small memorandum of openpyxl
A note about KornShell (ksh)
A note about TensorFlow Introduction
A memorandum regarding γ conversion
A little more about FIFO
A memorandum of using eigen3
A note about [python] __debug__
A memorandum when using beautiful soup
A memorandum to change to Manjaro Linux
Python: A Note About Classes 1 "Abstract"
[Python] A memorandum of beautiful soup4
A note about get_scorer in sklearn
A memorandum of files under conf.d
A story about using Python's reduce
A memorandum of closure survey contents
A note about mock (Python mock library)
[Memorandum] A story about trying OpenCV tutorial (face recognition) in a Windows environment
Memorandum / memo about programming learning / competitive programming site
A story about remodeling Lubuntu into a Chromebook
Memorandum about regression and binary classification metrics
A memorandum of using Python's input function
A memorandum of speed of arbitrary degree diagonalization
Memorandum of python beginners About inclusion notation
A Java programmer studied Python. (About type)
A story about machine learning with Kyasuket
[V11 ~] A memorandum to put in Misskey
A story about Python pop and append
Python Basic Memorandum Part 3-About Object Orientation-
Memo about Sphinx Part 1 (Creating a project)
A story about a 503 error on Heroku open
About February 02, 2020 * This is a Python article.
A memorandum of python string deletion process
A note about doing the Pyramid tutorial
A memorandum of trouble when formatting data