The Pandas dataframe.notnull()
function detects existing / non-missing values in a dataframe. The function returns a boolean that has the same size as the object to which it is applied, indicating whether each individual value is a na
value or not. All non-missing values are displayed as true, and missing values are displayed as false.
Note: Characters such as empty strings "or numpy.inf are not considered NA values. (unless you set pandas.options.mode.use_inf_as_na = True).
Syntax: DataFrame.notnull ()
Returns: Mask of bool values for each element in DataFrame that indicates whether an element is not an NA value.
Example # 1: Use notnull ()
to find all non-missing values in the data frame.
|
Let’s use the dataframe.notnull ()
function to find all non-missing values in the frame data.
|
Output:
As we can see in the output, everything is not missing values in the data frame have been matched against true. There is no false value since there is no missing value in the data frame
Example # 2: Use notnull ()
to find non-missing values when in notnull ()
there are missing values.
|
Output:
Note that an empty string is also displayed as true, indicating that it is not a NaN
value.