Deletion is one of the primary operations when it comes to data analysis. Very often we see that a particular attribute in the data frame is not at all useful for us while working on a specific analysis, rather having it may lead to problems and unnecessary change in the prediction. For example, if we want to analyze the students’ BMI of a particular school, then there is no need to have the religion column/attribute for the students, so we prefer to delete the column. Let us now see the syntax of deleting a column from a dataframe.
Let us now see few examples:
Note the column ‘Age” has been droped.
Note that the unnecessary column, ‘Religion’ has been deleted successfully.
- Get column index from column name of a given Pandas DataFrame
- Create a Pandas DataFrame from a Numpy array and specify the index column and column headers
- Convert given Pandas series into a dataframe with its index as another column on the dataframe
- Create a DataFrame from a Numpy array and specify the index column and column headers
- Python | Delete rows/columns from DataFrame using Pandas.drop()
- How to get column names in Pandas dataframe
- Capitalize first letter of a column in Pandas dataframe
- Python | Change column names and row indexes in Pandas DataFrame
- Convert the column type from string to datetime format in Pandas dataframe
- Apply uppercase to a column in Pandas dataframe
- How to lowercase column names in Pandas dataframe
- Get unique values from a column in Pandas DataFrame
- Adding new column to existing DataFrame in Pandas
- Get n-smallest values from a particular column in Pandas DataFrame
- Get n-largest values from a particular column in Pandas DataFrame
- Split a text column into two columns in Pandas DataFrame
- Create a column using for loop in Pandas Dataframe
- Getting Unique values from a column in Pandas dataframe
- Python | Creating a Pandas dataframe column based on a given condition
- Split a column in Pandas dataframe and get part of it
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.