Different types of missing values

The following are different types of missing values:

  • Not a Number (NaN): NaN is a placeholder for missing values for any data type. These can be created using numpy.nan. NaNs that are created using numpy.nan can be assigned to a nullable integer datatype. The missing value of an integer type is saved as a NaN. It is the default identifier of a missing value in Python.
  • NA: NA comes mostly from R, where NA is an identifier for a missing value.
  • NaT: This is equivalent to a NaN for timestamp data points.
  • None: This represents missing values of data types other than numeric.
  • Null: This originates when a function doesn't return a value or if the value is undefined.
  • Inf: Inf is infinitya value that is greater than any other value. inf is, therefore, smaller than any other value. It is generated by all the calculations, leading to very large or very small values. Often, we need to treat inf as a missing value. This can be done by specifying the following options in pandas:
pandas.options.mode.use_inf_as_na = True

A placeholder infinity variable can also be generated for comparison purposes, as shown in the following example:

import math
test = math.inf
test>pow(10,10) #Comparing whether Inf is larger than 10 to the power 10

It returns True.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset