I just want to check if a single cell in Pandas series is null or not i.e. to check if a value is NaN
.
All other answers are for series and arrays, but not for single value.
I have tried pandas.notnull
, pandas.isnull
, numpy.isnan
. Is there a solution for a single value only?
Check If any Value is NaN in pandas DataFrameUse DataFrame. isnull(). Values. any() method to check if there are any missing data in pandas DataFrame, missing data is represented as NaN or None values in DataFrame.
The math. isnan() method checks whether a value is NaN (Not a Number), or not. This method returns True if the specified value is a NaN, otherwise it returns False.
Try this:
import pandas as pd import numpy as np from pandas import * >>> L = [4, nan ,6] >>> df = Series(L) >>> df 0 4 1 NaN 2 6 >>> if(pd.isnull(df[1])): print "Found" Found >>> if(np.isnan(df[1])): print "Found" Found
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With