Syntax:
del(df['column_name'])
Note: Python maps this method to an internal method of DataFrame (df.__delitem__('column name')) which is responsible for the deletion of the column.
To work with Python Pandas, we need to import the pandas library. Below is the syntax,
import pandas as pd
Python code to delete a column from a Pandas DataFrame
Example 1:
Output:
Example 2:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer