I have a list that looks like this:
categorical_features = \
['FireplaceQu', 'BsmtQual', 'BsmtCond', 'GarageQual', 'GarageCond',
'ExterQual', 'ExterCond','HeatingQC', 'PoolQC', 'KitchenQual', 'BsmtFinType1',
'BsmtFinType2', 'Functional', 'Fence', 'BsmtExposure', 'GarageFinish', 'LandSlope',
'LotShape', 'PavedDrive', 'Street', 'Alley', 'CentralAir', 'MSSubClass', 'OverallQual',
'OverallCond', 'YrSold', 'MoSold']
I need to remove these columns from the dataset by doing this:
all_data = all_data.loc[:,categorical_features]
Unfortunately, this step only selects these columns. How would I reverse the process by excluding them instead?
You can use
pandas.drop
to exclude those columns:Look to the following example as a test:
The output: