Foreword:
In pandas, the `isna()` function is used to detect missing values (NaN values) in a DataFrame or Series. It returns a DataFrame or Series of Boolean values with True for missing value positions and False for non-missing value positions. The usage of `isna()` function is as follows:
对于dataframe:
DataFrame.isna()
对于Series:
Series.isna()
Example:
```python
import pandas as pd
# 创建一个示例DataFrame
data = {'Name': ['Alice', 'Bob', None, 'David'],
'Age': [25, 30, None, 40]}
df = pd.DataFrame(data)
# 检测DataFrame中的缺失值
print(df.isna())
```
输出结果:
```
Name Age
0 False False
1 False False
2 True True
3 False False
```
Notice:
In the above example, we use the `isna()` function to detect missing values in the DataFrame. The results show that both the "Name" and "Age" columns of row 3 contain missing values (NaN), and there are no missing values in other rows.
For Series objects, the `isna()` function is used similarly. it will return a