📜  Python|熊猫 dataframe.notnull()(1)

📅  最后修改于: 2023-12-03 15:04:26.763000             🧑  作者: Mango

Python Pandas DataFrame.notnull()

The notnull() function is a method in the Pandas library for Python, specifically designed to check for non-null values in a Pandas DataFrame.

Syntax

The basic syntax of the notnull() function is as follows:

DataFrame.notnull()
Parameters

The notnull() function does not take any parameters.

Return Value

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.

Example

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.

Conclusion

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.