📅  最后修改于: 2023-12-03 15:04:26.763000             🧑  作者: Mango
The notnull()
function is a method in the Pandas library for Python, specifically designed to check for non-null values in a Pandas DataFrame.
The basic syntax of the notnull()
function is as follows:
DataFrame.notnull()
The notnull()
function does not take any parameters.
The notnull()
function returns a boolean DataFrame that has the same shape as the original DataFrame, with each element being True if the corresponding element in the original DataFrame is not null, and False otherwise.
Consider the following example:
import pandas as pd
data = {'A': [1, 2, None, 4],
'B': [None, 6, 7, None],
'C': [8, 9, 10, 11]}
df = pd.DataFrame(data)
print(df.notnull())
Output:
A B C
0 True False True
1 True True True
2 False True True
3 True False True
In the above example, a DataFrame df
is created from a dictionary data
. The notnull()
function is then applied on the DataFrame and the resulting boolean DataFrame is printed.
It can be observed that the output DataFrame has the same shape as the original DataFrame, where each element is True if the corresponding element in the original DataFrame is not null, and False otherwise.
The notnull()
function is a useful method in Pandas for performing null value checks on DataFrame objects. By using this function, you can easily identify the location of non-null values in your data and perform subsequent operations based on the obtained boolean DataFrame.