How to Delete a column from Pandas DataFrame Last Updated : 05 Feb, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Deleting data is one of the primary operations when it comes to data analysis. Very often we see that a particular column in the DataFrame is not at all useful for us and having it may lead to problems so we have to delete that column. 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. Deleting a Column from DataFrameYou can remove column from a DataFrame using del Keyword. Let us now see the syntax to use del Keyword: Syntax:del df['column_name']Examples:Let's understand how to use the del keyword and delete columns from DataFrame in Python: Example 1: Python3 # importing the module import pandas as pd # creating a DataFrame my_df = {'Name': ['Rutuja', 'Anuja'], 'ID': [1, 2], 'Age': [20, 19]} df = pd.DataFrame(my_df) display("Original DataFrame") display(df) # deleting a column del df['Age'] display("DataFrame after deletion") display(df) Output : As you can see, the column 'Age' has been dropped. Example 2: Python3 # importing the module import pandas as pd # creating a DataFrame my_df = {'Students': ['A', 'B', 'C', 'D'], 'BMI': [22.7, 18.0, 21.4, 24.1], 'Religion': ['Hindu', 'Islam', 'Christian', 'Sikh']} df = pd.DataFrame(my_df) display("Original DataFrame") display(df) # deleting a column del df['Religion'] display("DataFrame after deletion") display(df) Output : Note that the unnecessary column, 'Religion' has been deleted successfully. Also Read: How to drop one or multiple columns in Pandas Dataframe ConclusionDeleting unnecessary columns is a very crucial step to clean data in data analysis. Not all attributes(columns) are useful to generate insights, so it's better to delete those columns from the DataFrame. Deleting a column in Pandas DataFrame is very easy. In this tutorial, we have shown how to delete a column/attribute from a Pandas DataFrame using del keyword. Comment More infoAdvertise with us Next Article How to delete columns in PySpark dataframe ? R rutujakawade24 Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame pandas-dataframe-program Practice Tags : python Similar Reads How to Find & Drop duplicate columns in a Pandas DataFrame? Letâs discuss How to Find and drop duplicate columns in a Pandas DataFrame. First, Letâs create a simple Dataframe with column names 'Name', 'Age', 'Domicile', and 'Age'/'Marks'. Find Duplicate Columns from a DataFrameTo find duplicate columns we need to iterate through all columns of a DataFrame a 4 min read How to add Empty Column to Dataframe in Pandas? In Pandas we add empty columns to a DataFrame to create placeholders for future data or handle missing values. We can assign empty columns using different methods depending on the type of placeholder value we want. In this article, we will see different methods to add empty columns and how each one 2 min read How to delete columns in PySpark dataframe ? In this article, we are going to delete columns in Pyspark dataframe. To do this we will be using the drop() function. This function can be used to remove values from the dataframe. Syntax: dataframe.drop('column name') Python code to create student dataframe with three columns: Python3 # importing 2 min read How to Get First Column of Pandas DataFrame? Getting the first column of a Pandas DataFrame is a frequent task when working with tabular data. Pandas provides multiple simple and efficient ways to extract a column, whether you want it as a Series (1D) or as a DataFrame (2D). Letâs explore the common methods to retrieve the first column of a Da 3 min read Python | Delete rows/columns from DataFrame using Pandas.drop() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages which makes importing and analyzing data much easier. In this article, we will how to delete a row in Excel using Pandas as well as delete 4 min read Show all columns of Pandas DataFrame Pandas sometimes hides some columns by default if the DataFrame is too wide. To view all the columns in a DataFrame pandas provides a simple way to change the display settings using the pd.set_option() function. This function allow you to control how many rows or columns are displayed in the output. 2 min read Like