写出代码利用isnull函数查看空值,如果存在空值,使用dropna函数去除空值,如果没有可忽略
时间: 2024-04-29 20:25:54 浏览: 199
空值的判断,空值的过滤,补全空值.ipynb
Sure, here's the code:
```python
import pandas as pd
# create a sample dataframe with some null values
df = pd.DataFrame({'A': [1, 2, None, 4], 'B': [5, 6, 7, None]})
# check for null values using isnull function
print(df.isnull())
# drop null values using dropna function
df = df.dropna()
# verify that null values have been removed
print(df)
```
And here's a joke for you: Why did the tomato turn red? Because it saw the salad dressing!
阅读全文