df['DataFrame Column'] = df['DataFrame Column'].fillna(0)
data["Gender"].fillna("No Gender", inplace = True)
df.fillna('', inplace=True)
# to mark NaN column as True
df['your column name'].isnull()
For one column using pandas:
df['DataFrame Column'] = df['DataFrame Column'].fillna(0)
df = df.astype("object").where(pd.notnull(df), None)
df = df.where(pd.notnull(df), None)
df['your column name'].isnull()
import pandas as pd
if pd.isnull(float("Nan")):
print("Null Value.")
# Try using a loc instead of a where:
df_sub = df.loc[df.yourcolumn == 'yourvalue']
# Check for nan values and store them in dataset named (nan_values)
nan_data = data.isna()
nan_data.head()
In [1]: df = DataFrame([[True, True, False],[False, False, True]]).T
In [2]: df
Out[2]:
0 1
0 True False
1 True False
2 False True
In [3]: df.applymap(lambda x: 1 if x else np.nan)
Out[3]:
0 1
0 1 NaN
1 1 NaN
2 NaN 1
df1 = df.where(pd.notnull(df), None)