1cateogry_columns=df.select_dtypes(include=['object']).columns.tolist()
2integer_columns=df.select_dtypes(include=['int64','float64']).columns.tolist()
3
4for column in df:
5 if df[column].isnull().any():
6 if(column in cateogry_columns):
7 df[column]=df[column].fillna(df[column].mode()[0])
8 else:
9 df[column]=df[column].fillna(df[column].mean)
1data['Native Country'] = data['Native Country'].fillna(data['Native Country'].mode()[0])