The isna method in pandas detect missing values in a dataframe. It return a boolean same-sized object indicating if the values are NA. NA values, such as None or
numpy.NaN, gets mapped to True values. Everything else gets mapped to False values.
Let’s read a dataset to work with.
import pandas as pd url = 'https://raw.githubusercontent.com/bprasad26/lwd/master/data/fruit_prices.csv' df = pd.read_csv(url) df.head()
1 . Show which entries in a DataFrame are NA –
To show which entries are NA in a DataFrame, we can use the isna() method in pandas.
2 . Show which entries in a series are NA –
We can also use isna method with a series.
# create a series s = df['apple'] # check which entries in the series are NA s.isna()