How to impute missing values of categorical data?

My categorical dataset contains missing values. During data preprocessing, I want to remove missing values with the category that fits best. I’m a beginner and don’t know much about handling missing values and imputing categorical data. During the research, I found a method but I’m not sure about its working. It is based on simple imputer.

Can someone explain the code I showed above and share with me some ways to impute missing values in my data with different imputers Scikit-learn provides?