Here is what I did but feels like there’s simpler:
[numerical_columns.remove(x) for x in numerical_features]
categorical_columns_total = categorical_columns + numerical_columns
Here is what I did but feels like there’s simpler:
[numerical_columns.remove(x) for x in numerical_features]
categorical_columns_total = categorical_columns + numerical_columns
I used set subtraction.
categorical_features = list(set(data.columns) - set(numerical_features))
There did was a Pythonic way to do, I knew it… Thank you very much for the hint
Since you are manipulating Pandas indices, you can directly use their interface instead to convert into Python set:
categorical_features = data.columns.difference(numerical_features)
This is the Pandastic solution
we can also use:
categorical_features = data.drop(columns=numerical_features).columns