text_html_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('/kaggle/input/home-data-for-ml-course/train.csv')
test = pd.read_csv('/kaggle/input/home-data-for-ml-course/train.csv')

numerical_cols = [col for col in X_train_full.columns if X_train_full[col].dtype == 'int64' or X_train_full[col].dtype == 'float64']

categorical_cols_prev = [col for col in X_train_full.columns if X_train_full[col].dtype == 'object' and X_train_full[col].nunique() > 4]
categorical_cols = []
for col in categorical_cols_prev:
    if set(list(test[col].unique())).issubset(set(list(X_train_full[col].unique()))):
        categorical_cols.append(col)
print(len(categorical_cols))