Séparation de fonctionnalité numérique et catégorique à l'aide de LOOP

# create a list of all categorical variables
# initiate an empty list to store the categorical variables
categorical=[]

# use for loop to check the data type of each variable
for column in df_vaccine:
    
    # use 'if' statement with condition to check the categorical type 
    if is_string_dtype(df_vaccine[column]):
        
        # append the variables with 'categoric' data type in the list 'categorical'
        categorical.append(column)
# dataframe with categorical features
# 'categorical' contains a list of categorical variables
df_cat = df_vaccine[categorical]

# dataframe with numerical features
# use 'drop()' to drop the categorical variables
# 'axis = 1' drops the corresponding column(s)
df_num = df_vaccine.drop(categorical, axis = 1)      
Helpful Hare