impute mode pandas

cols = ["workclass", "native-country"]
df[cols]=df[cols].fillna(df.mode().iloc[0])

Here is what the above code is Doing:
1. We’re creating a list of columns that have missing values.
2. We’re filling the missing values in those columns with the mode of the column.
3. We’re assigning the result back to the original dataframe.