The drop function removes the columns from the data without affecting the rest of the features.
data.drop(['column_name'], axis=1, inplace=True)
The axis parameter present inside the function can take the below values:
1. axis=0 is set to remove the index (rows).
2. axis=1 is set to remove the columns.
We have set the axis parameter to remove the columns we don't want, i. e. axis=1
The inplace determines the changes in the data.
1. When inplace=True, the car_dummy data will drop features passed in the function permanently from the data.
2. When inplace=False, the car_dummy data will drop features, However, no permanent change will appear.
In order to drop multiple columns:
data.drop(['column_name1','column_name2','column_name3'], axis=1, inplace=True)
Comments
0 comments
Article is closed for comments.