Google News
logo
Pandas - Interview Questions
How will you identify and deal with missing values in a dataframe?
We can identify if a dataframe has missing values by using the isnull() and isna() methods.

missing_data_count=df.isnull().sum()


We can handle missing values by either replacing the values in the column with 0 as follows:

df[‘column_name’].fillna(0)


Or by replacing it with the mean value of the column

df[‘column_name’] = df[‘column_name’].fillna((df[‘column_name’].mean()))

Advertisement