.isnull()
vs .isna()
for pandas.
Sample code:
import pandas as pd
import numpy as np
df = pd.DataFrame({ 'object': ['a', 'b', 'c',pd.NA],
'numeric': [1, 2, np.nan , 4],
})
creates data frame df
that looks like:
| | object | numeric | categorical |
|---:|:---------|----------:|:--------------|
| 0 | a | 1 | d |
| 1 | b | 2 | nan |
| 2 | c | nan | f |
| 3 | <NA> | 4 | g |
Testing .isnull()
and .isna()
:
pd.isnull(df.iloc[3,0])
Out[165]: True
pd.isnull(df.iloc[2,1])
Out[166]: True
pd.isna(df.iloc[3,0])
Out[167]: True
pd.isna(df.iloc[2,1])
Out[168]: True
Here both .isnull()
and .isna()
give same result.
Question: Which one to use with pandas and why to use? What are main advantages and disadvantages of each of them with pandas?