notna(), aliased identically as notnull(), is functionally equivalent to negating the result of isna(), provided as a separate, readable method so code that specifically cares about present values doesn't need an extra negation to express that intent. It's commonly used with boolean indexing to select only the rows that do have a value in a specific column, the mirror image of using isna() to find the rows that don't.
1Understanding df.notna()
notna(), aliased identically as notnull(), is functionally equivalent to negating the result of isna(), provided as a separate, readable method so code that specifically cares about present values doesn't need an extra negation to express that intent. It's commonly used with boolean indexing to select only the rows that do have a value in a specific column, the mirror image of using isna() to find the rows that don't.
df.notna() and negating df.isna() are exactly equivalent — use notna() directly whenever your logic is naturally phrased as selecting the values that are present, instead of an extra negation on isna().
import pandas as pd
import numpy as np
df = pd.DataFrame({"email": ["a@x.com", np.nan, "c@x.com"]})
print(df["email"].notna())2Practical Example
Here is a real-world application of df.notna() showing how it is used in production Pandas code.
import pandas as pd
import numpy as np
df = pd.DataFrame({"name": ["Alice", "Bob", "Carol"], "email": ["a@x.com", np.nan, "c@x.com"]})
has_email = df[df["email"].notna()]
print(has_email)3Best Practices
Follow these guidelines when working with df.notna():
1. Use notna() directly when your logic is naturally about selecting present values, rather than writing an explicit negation of isna()
2. Combine notna() with boolean indexing to select only rows with a value in a specific required column
3. Use notna().sum() to count non-missing values per column, the mirror image of isna().sum() for counting missing ones
Tip: df.notna() and negating df.isna() are exactly equivalent — use notna() directly whenever your logic is naturally phrased as selecting the values that are present, instead of an extra negation on isna().
import pandas as pd
import numpy as np
df = pd.DataFrame({"email": ["a@x.com", np.nan, "c@x.com"]})
print(df["email"].notna())