Python Pandas – Delete a column

In this post we will be creating a Python script that will delete a column within a Pandas data frame. Pandas is a Python library which is an amazing tool for data analysis and manipulation.

See a snippet of our data frame for this example below.

The column we will be deleting from our data frame is ‘Name’, in this example our data frame is loaded from an existing CSV file. See the snippet of code below for how this is done.

import pandas as pd

df = pd.read_csv('Sample.csv')

df = df.drop('Name', axis=1)

Leave a Reply