flowchart LR A([Handling NA]) --> B(dropna) A --> C(fillna) A --> D(isnull) A --> E(notnull) C --> F[ffill] C --> G[bfill]
Handling missing data
python
pandas
numpy
Examples of dealing with missing data
In Pandas, there are 4 methods to handle NA
values, which are dropna
, fillna
, isnull
, notnull
.
import pandas as pd
import numpy as np
= pd.Series(['apple', 'orange', np.nan, 'avocado'])
string_data string_data
0 apple
1 orange
2 NaN
3 avocado
dtype: object
string_data.isna()
0 False
1 False
2 True
3 False
dtype: bool
string_data.isnull()
0 False
1 False
2 True
3 False
dtype: bool
0] = None string_data[
string_data.isnull()
0 True
1 False
2 True
3 False
dtype: bool
string_data.notnull()
0 False
1 True
2 False
3 True
dtype: bool