The notna method in pandas detect existing (non-missing) values in a dataframe or series. It return a boolean same-sized object indicating if the values are not NA. Non-missing values get mapped to True.
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 not NA –
To show which entries in a DataFrame are not NA, we can use the notna method in pandas.
2 . Show which entries in a Series are not NA –
We can also use notna method with a series.
# create a series s = df['apple'] # check which entries in the series are not NA s.notna()