Please note that this is a memorandum for yourself.
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.
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.
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.
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.
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