To check if a value is not NA in Python using Pandas library, we can use notna()
function which returns a boolean mask indicating where the values in a DataFrame are not NA.
Here is an example:
main.py250 chars12 lines
Output:
main.py148 chars16 lines
In the code above, we create a Pandas series s
with some NA values, then we use the notna()
function to create a boolean mask mask
indicating which values are not NA. Finally, we print both the original series and the mask to see the results.
We can also use isna()
function to check if a value is NA. It will return the opposite of notna()
function.
gistlibby LogSnag